Monday, 27 February 2012

what is partial class in asp.net

Definition : A class defined in  two or more files is called a partial class. The keyword partial is used to define the class. When working on large projects, spreading a class over separate files allows multiple programmers to work on it simultaneously. During compile time all the partial class are compiled into one type only.

public partial class PartialClass
{
    public void MethodA()
    {
        Console.WriteLine("I am A!");
    }
}

public partial class PartialClass
{
    public void MethodB()
    {
        Console.WriteLine("I am B!");
    }
}


If we try to call methods of this class we can see something like this on screen.
Methods of partial class

No comments:

Post a Comment