GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Microsoft  >  Microsoft.NET

 Print  |  
Question:  what is the concept of partial class in .net2.0?



June 06, 2007 05:38:06 #1
 Rajesh Bathala   Member Since: Visitor    Total Comments: N/A 

RE: what is the concept of partial class in .net2.0?
 

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
     

 

Back To Question