+ 3
Can I use keyword “var” in function (method)?
The “var” keyword is universal keyword for each type, but I can’t change a type – I now. But can I use this keyword in arguments of method, for example: using System; ... public string GetSum(var num) { return num.ToString() + " + 3 = " + (Int32.Parse(num) + 3); } ... byte a = 3; GetSum(a); Int32 b = 4; GetSum(b);
3 Respostas
+ 3
It's not valid,var is not really a type.
https://stackoverflow.com/questions/14281289/passing-type-var-into-a-method-in-c-sharp
+ 3
Thank you for your answer. 😃