using System;
public class Program
{
public void Main()
int myVal = 0;
myVal = MethodByVal(myVal);
int myRef = 0;
MethodByRef(ref myRef);
Console.WriteLine("By val: {0}" , myVal); //returns 'By val: 30'
Console.WriteLine("By ref: {0}" , myRef); //returns 'By ref: 30'
}
private int MethodByVal (int intByVal) {
return intByVal + 30;
private void MethodByRef (ref int intByRef) {
intByRef += 30;