+ 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 Answers
+ 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. đ