Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

Can we return two values from a function?

Answers were Sorted based on User's Feedback

Can we return two values from a function?..

Function always returns only one return value.
In other word, function cannot have a multiple return value.

The out or ref parameter can be used to trick the problem. However the return value still only one since Even the void function/method return 'null' value.

 Is This Answer Correct ? 13 Yes 0 No

Can we return two values from a function?..

Using return statment, it is not possible to return more
than one value but if we use the Out parameters then we can
have return more than one value depanding upon how many
parameters u have given as Out Parameter.

 Is This Answer Correct ? 6 Yes 1 No

Can we return two values from a function?..

Function should have only one return statement,whereas
using out parameter its possible to send more than on value.

 Is This Answer Correct ? 4 Yes 0 No

Can we return two values from a function?..

with the help of out paraeter we can return two value from
function

 Is This Answer Correct ? 4 Yes 1 No

Can we return two values from a function?..

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;
then the value of e will be 5 and the value of d will be 3.

 Is This Answer Correct ? 9 Yes 8 No

Can we return two values from a function?..

in c# a function can return two values with the help of out
parameter.

 Is This Answer Correct ? 3 Yes 2 No

Can we return two values from a function?..

yes we can return two values with the help of out keyword

 Is This Answer Correct ? 4 Yes 4 No

Can we return two values from a function?..

I think yes.. Function can return multiple values.. It's
not good practice.. but C# allows you.. Consider following
example

int Val;
GetValue(Val);

bool GetValue(out int Val)
{
Val = value;
return true;
}

 Is This Answer Correct ? 4 Yes 5 No

Can we return two values from a function?..

Guys, you will be able to return n number of values, while
you are using arraylist.

 Is This Answer Correct ? 6 Yes 9 No

Can we return two values from a function?..

No
only one value will return at a time but function may have
multiple output statement ..

 Is This Answer Correct ? 1 Yes 7 No

More C Sharp Interview Questions

Where do we set the min and max pool size for connection pooling?

What are the properties of c#?

Explain publishers and subscribers in events.

C# called c sharp why?

What is xml serialization and deserialization in c#?

What is difference between float and decimal?

Is it possible to inherit multiple interfaces?

destructor, Dispose, Finalize - How they relate to each other

What is meant by unicode characters?

What is dataset c#?

What is string [] args in c#?

what does static void Main(string[] args) in C# mean????????

Categories