What is the concept of partial class in .net2.0?

Showing Answers 1 - 6 of 6 Answers

Rajesh Bathala

  • Jun 13th, 2007
 


Partial class allows developers to split a class into multiple files.


ex:

public partial class A
{
    A()
   
    {
        //constructor here

    }

}

Suppose another developer needs to add a new function to it called updated A , the other developer can creat a new file call it A1.cs and it should be look something like this.

public partial cllass A

{
  public void update A()
  {
     // function code goes here
    }
}


while using partial classes ,if we have declared a constructor or a function in one source file, we can not define the same in the other partial source file.

  The .NET runtime executes  these two classes it treats  two or multiple source file as one single class A.


Regards

Rajesh Bathala

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions