Partial classes is one of the coolest feature added to C# language. Having partial classes in the language provides programmers to write cleaner interfaces. A partial class means "A single class can be defined in multiple physical files.". For example, I can have a ClassA, which is defined in three different AFile.cs, BFile.cs, and CFile.cs physical files.
Now you may ask why would I want that? Do you remember ASP.NET or Windows Forms applications, where designer (Visual Studio IDE) generated code was written in a region and your code will be added after that. When writing larger user interface driven applications (for example Windows UI or Web UI), you may want to have user interfaces related code in a file, some logic in a separate file and so on. Now using partial classes, we can have designer generated code in a separate file, control event handlers in a separate file, and rest of the code in a separate file.
|
No responses found. Be the first to respond and make money from revenue sharing program.
|