What is partial class. & what is advantage ?

 Posted by Bharathi Cherukuri on 4/24/2012 | Category: C# Interview questions | Views: 12867 | Points: 40
Answer:

Partial class is a keyword which is used to split the defiition of the class into multiple parts with same singature.
When complier compiles the class file ,it makes into single file.

Example:

Public partial class HRModule

{
public void DoWork()
{}
}

Public partial class HRModule
{
public void GoToLunch()
{
}
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Akiii on: 4/25/2012 | Points: 10
You didn't mention the advantages ?


Regards
Akiii
Posted by: Bharathi Cherukuri on: 4/26/2012 | Points: 10
Purpose of partial classes is to allow a class's definition to span across multiple files.
This can allow better maintainability and separation of your code.
That way it's easier to check out a part of the code with Sourcesafe.
This limits the cases where four developers need to access the same file.

Regards,
Bharathi
Posted by: Akiii on: 4/26/2012 | Points: 10
Thats good bharati..

Regards
Akiii
Posted by: Etechpulse on: 4/4/2014 | Points: 10

Login to post response