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 ienumerable and iqueryable?

498


What can we do to handle multiple exceptions?

548


How do I trim a space in c#?

434


What is javascriptserializer c#?

496


What is the difference between selection and projection?

427






Is c# a strongly-typed language?

537


What is a destructor in c#?

515


What is code verification?

527


What is xpath in c#?

476


Is c# a technology?

482


What is tpl in c#?

490


What is the difference between static class and sealed class in c#?

459


How do I declare a pure virtual function in c#?

582


We cannot create instances of static classes. Can we have constructors for static classes?

508


What is data dictionary in c#?

480