The ref keyword on a method parameter causes a method to refer to the same variable that was passed as an input parameter for the same method. If you do any changes to the variable, they will be reflected in the variable.You can even use ref for more than one method parameters. namespace TestRefP { using System; public class myClass { public static void RefTest(ref int iVal1 ) { iVal1 += 2; } public static void Main() { int i; // variable need not be initialized i = 3; RefTest(ref i ); Console.WriteLine(i); } } }
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: