static void Main(string[] args) { // // For STRUCT // var studentStruct0 = new StudentStruct(); // var studentStruct1 = new StudentStruct(1); // var studentStruct2 = new StudentStruct(2, 3); // // Instance // studentStruct1.WriteAge(); // // Static // StudentStruct.WriteAge(studentStruct1); // For Class var studentClass0 = new StudentClass(); studentClass0.Age = 2; Console.WriteLine(studentClass0.Age); studentClass0.Mass = 3; studentClass0.WriteAge(); var studentClass1 = new StudentClass(1); var studentClass2 = new StudentClass(2, "3"); // Instance studentClass1.WriteAge(); // Static StudentClass.WriteAge(studentClass1); }
/// <summary> /// Статический метод который выводит возраст /// </summary> /// <param name="studentClass">the <see cref="StudentClass"/></param> public static void WriteAge(StudentClass studentClass) { Console.WriteLine("Age is:" + studentClass._age); }