What are partial class in C#? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What are partial class in C#?

please explain me

12th Mar 2017, 9:09 AM
gaurav kulkarni
gaurav kulkarni - avatar
2 Answers
+ 1
You can use the partial keyword when defining a class in C# if you want to break it up across multiple files. When the code gets compiled it combines all the partial class files with the same name into one class. This can be useful if you have a very large class and you want to break the methods up into several files to make it easier to maintain. It can also help if you have more than one person working on the class at a time, since they can work on their partial class file but the system will interpret it as one class.
12th Mar 2017, 10:53 AM
Frans Booysen
Frans Booysen - avatar
+ 1
Normally you can't split a class in two different files, but using partial modifier you can separate a class in two different files. It could be useful when you are used to modify only one file of it while you rarely touch the other (or when it is automatic-generrated)
12th Mar 2017, 10:53 AM
GDC