static void Main(string[] args) { Worker worker = new Worker(); Request request = new Request(); request.Id = 4; Console.WriteLine(request.Id + " : " + request.GetHashCode()); worker.PassByReference(ref request); Console.WriteLine(request.Id + " : " + request.GetHashCode()); GC.Collect(); Thread.Sleep(1000); Console.WriteLine(request.Id + " : " + request.GetHashCode()); Console.ReadLine(); }
public void ValueChanger(Request request) { Console.WriteLine(request.Id + " : " + request.GetHashCode()); request = new Request(); request.Id = 6; }
public void PassByReference(ref Request request) { request = new Request(); request.Id = 6; }