Object Oriented Programming and C#: Partial Classes

The “partial” keyword can be used in C# to create partial classes. These are classes that split the functionality of a single class into multiple files which are combined into a single file when the program is compiled. The following image conveys the basic idea behind a partial class. The main class is called “Geeks” which has two partial classes which individually contain a different function of the main class.


With partial classes, a method that is created in one file can be used in another. It is effectively splitting the use of one class into multiple files. This can be helpful if the class is too large to effectively or when a class that should not be modified needs additional information added to it. The following code snipped shows a method (“GetName”) being executed which exists in a separate file.