Exemplo n.º 1
0
 public static void Main(string[] args)
 {
     Student student = new Student();
     // Set the name by accessing it directly.
     Console.WriteLine("The first time:");
     student.name = "Madeleine";
     Student.OutputName(student); // Method now belongs to Student.
     // Change the name using a method.
     Console.WriteLine("After being modified:");
     Student.SetName(student, "Willa");
     Student.OutputName(student);
     // Wait for user to acknowledge.
     Console.WriteLine("Press Enter to terminate...");
     Console.Read();
 }
Exemplo n.º 2
0
 // SetName -- Modify the student object's name.
 public static void SetName(Student student, string name)
 {
     student.name = name;
 }
Exemplo n.º 3
0
 // OutputName -- Output the student's name.
 public static void OutputName(Student student)
 {
     // Output current student's name.
     Console.WriteLine("Student's name is {0}", student.name);
 }
Exemplo n.º 4
0
 // SetName - Modify the student object's name.
 public static void SetName(Student student, string name)
 {
   student.name = name;
 }
Exemplo n.º 5
0
 // OutputName - Output the student's name.
 public static void OutputName(Student student)
 {
   // Output current student's name.
   Console.WriteLine("Student's name is {0}", student.name);
 }