static void Main(string[] args) { Student s1 = new Student(); s1.RollNumber = 2; ChangeRollNumber(ref s1); Console.WriteLine(s1.RollNumber); StudentStruct studentStruct = new StudentStruct(); studentStruct.RN = 22; ChangeRollNumberForStruct(ref studentStruct); Console.WriteLine(studentStruct.RN); Console.ReadKey(); }
private static void ChangeRollNumberForStruct(ref StudentStruct studentStructInput) { studentStructInput.RN = 33; studentStructInput = new StudentStruct(); studentStructInput.RN = 55; }