public static void ConvertStudentName(string name) { // you can not use an instance member Age var student = new Student(); if (student.Age>0) { } }
//The method some times is like a contract, What you pass in and what ir returns public List<Student> GetStudents() { List<Student> list1 = new List<Student>(); Student student1 = new Student(); list1.Add(student1); Student student2 = new Student(); list1.Add(student2); return list1; }
static void TestStudent() { // here is an example of calling static Student.ConvertStudentName("myname"); Student studentTest = new Student(); Student studentTest2 = new Student(19); studentTest.Age = -10; Console.WriteLine(studentTest.Age); studentTest.LastName = "Gao"; Console.WriteLine(studentTest.LastName); Console.ReadLine(); }