Monday 29 June 2015

What is mean by Partial class?

It is new features in .Net 2.0; partial classes mean that class definition can be split into multiple physical files. Logically, partial classes do not make any difference to the compiler. The compiler intelligently combines the definitions together into a single class at compile-time

Customer1.cs:-
partial class Customer
    {
        int age;
        public int Age
        {
            get { return age; }
            set { age = value; }
        }
        public void GetDeyails(int id)
        {
            GetEmpName(id);
        }
        partial  void GetEmpName(int id)
        {
            Console.Write("Employee1");
        }
    }

customer1.cs
partial class Customer
    {
        string name ;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
         partial void GetEmpName(int id);
    }

static void Main(string[] args)
{
 Customer cust = new Customer();
            cust.Name = "SKM";
            cust.Age = 123;
            //string res;
            cust.GetDeyails(1);
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.