Can we return two values from a function?

Answer Posted / tarun kumar

yes.
for example:
public int Add(int a,int b,out int c)
{
c=a+1;
return a+b;
}
when we call the Add method we will get the sum of the a
and b and can also use the value of c
like
int d=0;
int e= Add(2,3,d) ;
then the value of e will be 5 and the value of d will be 3.

Is This Answer Correct ?    9 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of getcommandlineargs() method in c#.net?

723


What is the difference between func and action delegate?

685


Differentiate between the public and private ?

737


What is the difference between an implicit conversion and an explicit conversion?

683


What is the use of base keyword? Tell me a practical example for base keyword’s usage?

708


How do I run managed code in a process?

710


Does unity require coding?

734


What is gui in c#?

751


How do I do implement a assert?

714


Can a constructor have a return type?

682


What is a Command Object in C#?

728


Can we overload indexer in c#?

663


What is c# entity framework?

652


What is the default scope of a class in c#?

676


Explain about finalize method?

721