1.) Shall we use output (out keyword or ref keyword) parameters inside a value returning method?
Please explain me Why or why not??
with an example...
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Francis SusaimichaelPosted Feb 17, 2016, 7:50 AM
1.) It is must to use the return keyword here?
It depends on your requirement. if you want to return you can use otherwise leave it.
Y GPosted Feb 17, 2016, 8:32 AM
Y GPosted Feb 17, 2016, 2:14 AM
Francis SusaimichaelPosted Feb 17, 2016, 2:01 AM
Shall we use output (out keyword or ref keyword) parameters inside a value returning method?
Yes. you are free to use. There is no restriction. Consider the below example:
public int add(out int param1,ref int param2)
{
param1 = 100;
param1 = param1 + param2;
return param1;
}
Also you can call this method anywhere in the class like below:int a;
int b = 10;
Response.Write(add(out a, ref b));
Amit Kumar SinghPosted Feb 17, 2016, 1:22 AM