How to return a value from method having return type as void? [Resolved]

Posted by Shreedar under C# on 8/15/2015 | Points: 10 | Views : 467 | Status : [Member] | Replies : 2
Hi

In one of my interview, I faced a question that how can you return a value from method, which has void return type.

Regards

Sridhar Thota.
www.dotnet-sridhar.blogspot.com



Responses

Posted by: Sheonarayan on: 8/18/2015 [Administrator] HonoraryPlatinum | Points: 50

Up
0
Down

Resolved
You can use out parameter.

Read this beautiful article http://www.dotnetfunda.com/articles/show/2953/parameters-ref-and-out-modifiers-in-csharp
http://www.dotnetfunda.com/articles/show/1526/csharp-out-parameter-explored

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Shreedar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajnilari2015 on: 9/28/2015 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
Also you can use Ref.Works!!!

--
Thanks & Regards,
RNA Team

Shreedar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response