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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Francis SusaimichaelRank #466 · 5.4K reputationPosted Feb 17, 2016, 2:50 AM EST
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.
Amit Kumar SinghRank #562 · 4.3K reputationPosted Feb 16, 2016, 8:22 PM EST
Francis SusaimichaelRank #466 · 5.4K reputationPosted Feb 16, 2016, 9:01 PM EST
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));
Y G173 reputationPosted Feb 16, 2016, 9:14 PM EST
Y G173 reputationPosted Feb 17, 2016, 3:32 AM EST