Re: C# using out in method parameter list with array as argument

Posted 24 April 2011 - 06:01 AM

This a class lab. The instructor is trying to demonstrate how to us 'out'. To [email protected], hi, thanks for the input. Could you include a small snipet of code that illustrates your point. Much thanks.

Re: C# using out in method parameter list with array as argument

Re: C# using out in method parameter list with array as argument

Posted 24 April 2011 - 09:00 AM

Thank you to jackofalltrades. Your answer was so helpful. I see you have been in the system for a long time. You explain things in a consise and well worded way. Thank you again. By the way this is c# and you directed me to c and c++ manuals. I have three manuals and none of them covers passing an array by using out. I have looked on the web extensively. But you are a bright shiny example of help here.
Thank you again for your incredible assistance!

Re: C# using out in method parameter list with array as argument

Posted 24 April 2011 - 10:49 AM

"Your kind of help"? Dude...he linked you to working source code. What more do you want?! And he is a moderator...he knows what he's doing. I'm sorry if you found it rude, but truly, he's trying to show you a valid, good source of information. MSDN IS the definitive resource for Microsoft-based languages.

Re: C# using out in method parameter list with array as argument

Posted 24 April 2011 - 11:45 AM

@macosxnerd101 ,

WTF is that

@OP

Quote

Thank you to jackofalltrades. Your answer was so helpful. I see you have been in the system for a long time. You explain things in a consise and well worded way. Thank you again. By the way this is c# and you directed me to c and c++ manuals. I have three manuals and none of them covers passing an array by using out. I have looked on the web extensively. But you are a bright shiny example of help here.
Thank you again for your incredible assistance!

Well that is C# , if you dont know that , then you should not be studying the out keyword now ..

Anyway to make this topic somewhat useful i will give the answer

/* Some method you have */
void Get()
{
int sum ;//Declare DataType
Add(10,12,out sum);//This will return sum
Console.Write(sum);//This will now contain a value of 22
}
void Add(int x, int i,out sum)//Sum will now be returned.
{
//assign value to int because it was empty
i = x + i;//Returns i
}

BTW:

This is not needed in this case
it can easily be written..

int Add(int x , int i)
{
return x + i;
}

The only reason you want to use "out" is when you want to return more that 1 value

Re: C# using out in method parameter list with array as argument

I'm sorry if you found it rude, but truly, he's trying to show you a valid, good source of information. MSDN IS the definitive resource for Microsoft-based languages.

THIS. I wanted to point you to the most valuable treasure trove of information available on the web for C# and Microsoft development: the Microsoft Developers' Network or MSDN. Everything you could want to know about C# is right there for the taking. Every Windows developer SHOULD know about MSDN, because every developer should be as self-sufficient as possible and adept at using the vast amount of information available to him.

I use so many different tools and languages in my "real job" (yes, I do have one, thank you very much) on a daily basis that I live on Google or MSDN. Knowing how to find what you need is as important as knowing how to write the code.