Partial classes can be used to split definitions of classes, structs or interfaces over two or more source files. Each source file contains a section of the class definition which are combined at when the application is compiled.
Partial classes can be beneficial in the following situations:
- Working on large projects, allowing developers to work on different sections of a class without both having to access the same physical file.
- Working with generated source code, as code can be added to a class without touching the original source file.
- Improve maintainability by logically grouping code.
An interface is a contract between classes. An interface is particularly powerful in C# as it allows multiple inheritance.
Interfaces are abstract types that contain no actual data but simply expose behaviours to the classes that implements them.
Generics use type parameters, which allow classes and methods that can defer specification until they are instantiated.
- Maximises code reuse, type safety and performance.
- Most common use in collections