Why do we need to use out keyword while calling a method

Posted by Midhat on Stack Overflow See other posts from Stack Overflow or by Midhat
Published on 2010-06-18T06:42:58Z Indexed on 2010/06/18 6:53 UTC
Read the original article Hit count: 318

Filed under:
|
|

When a method is defined with an out parameter, why do I have to specify the out keyword when calling it. Its already there in the method definition, and the runtime should know that any parameter passed will be an out parameter.

It would make sense if the compiler will accept the argument with or without out keyword, with different semantic, but if you MUST add the keyword to make the code compile, whats the use? Shouldn't the compiler handle it automatically?

Same for ref

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET