C# Partial Classes and Methods: One of the unique features of C# is the concept of Partial, extendable to definition of a Class or a Struct, an Interface or a method. Using this, the definition of any class, struct, interface of method can exist in two or more source files. Each source file contains a section of the type or method definition, and all parts are combined when the application is compiled. To split a class definition, partial keyword modifier is used. For Example: public partial class Pradeep { public void OnLeave () { } } public partial class Pradeep { public void InMeeting () { } } Here, it is valid to use the same name for the class and implement desired functionality separately. Finally, when compiled, the code is auto merged , giving a Final class named Pradeep, with the two methods that were defined separately. The partial keyword indicates that other parts of the class, struct, or interface can be defined in the namespace. Following are...
Comments
Post a Comment