1. Back To Blog

C# interview questions: - How will you explain partial classes in C# and .NET?

A partial class allows a single class to be divided in to two separate physical files. During compile time these files get compiled in to single class. For instance you can see in the below figure we have the customer class divided in to two different files "customer1.cs" and "customer2.cs".

 

During compilation these files gets compiled in to single class internally. So when you create an object of the customer class you will be able to see methods lying in both the physical files. For instance you can see "Add" method belongs to "customer1.cs" and "Delete" method belongs to "customer2.cs" , but when the customer object is created we can see both "Add" and "Delete" methods.

 

Figure: -

 

Also want to see in the form of video to understand in better form see the following video on partial class: -

 

 

Visit for more important c# interview questions

 

Regards,

 

For more author's blog on c# interview questions and answers

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social