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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s