0

Methods parameters with out keyword

Hi everyone, in tutorial, i have this code: _______________________________________ static void Ask(out string name) { name = Console.ReadLine(); } static void Main(string[] args) { string nm; Ask(out nm); } _______________________________________ I don't see a declaration for "name", I imagine it is implicitly declared in the ASK function. C# is sometimes strange in its syntax and logic ..

5th Jun 2020, 2:06 PM
Alain Mazy
Alain Mazy - avatar
2 Answers
0
Within `Main` method, the string variable <nm> is declared. It then be passed to `Ask` method and will act and be treated as <name> variable wirhin the `Ask` method. Console input will be assigned to <name> (which actually is <nm>) and the assignment will reflect in the `Main` method. Is this what you were asking for? cause I'm not too sure I got your question all so clear ...
5th Jun 2020, 2:21 PM
Ipang
0
Yes, thanks.
18th Jul 2020, 12:49 PM
Alain Mazy
Alain Mazy - avatar