CSharp examples for Custom Type:Method Parameter
Demonstrate how to pass an object to a method.
using System;/* w ww .ja va2s . c o m*/ public class Student { public string name; } public class Program { public static void Main(string[] args) { Student student = new Student(); Console.WriteLine("The first time:"); student.name = "M"; OutputName(student); Console.WriteLine("After being modified:"); SetName(student, "new"); OutputName(student); } public static void OutputName(Student student) { Console.WriteLine("Student's name is {0}", student.name); } public static void SetName(Student student, string name) { student.name = name; } }