Invoke a member method through the object. - CSharp Custom Type

CSharp examples for Custom Type:Method

Description

Invoke a member method through the object.

Demo Code

using System;//  ww w  .j ava 2s.  c o m
class Student
{
   public string firstName;
   public string lastName;
   public void SetName(string fName, string lName)
   {
      firstName = fName;
      lastName  = lName;
   }
   public string ToNameString()
   {
      string s = firstName + " " + lastName;
      return s;
   }
}
public class Program
{
   public static void Main()
   {
      Student student = new Student();
      student.SetName("S", "D");
      Console.WriteLine("Student's name is " + student.ToNameString());
   }
}

Result


Related Tutorials