Skip to main content

Posts

Showing posts from July, 2020

Partial Methods in C#

Partial Methods in C# Explained The  partial method  is a special type of method which will contain a declaration part in one  partial class  and the definition part in another  partial class  or in the same  partial class .   Generally, the partial methods will exist either in partial  class  or  struct  and it will contain two main parts one is  declaration  and  definition . Here, the  declaration  part represents a signature of the partial method and the  definition  part will represent an implementation of the partial method.   In the partial method, the definition part is optional so it may or may not have an implementation in  partial classes . In case, the implementation part of the partial method is not available in any partial class, then the compiler will remove the definition of the method and all the calls related to that particular method in the final class. ...

Partial class in C#

Partial class in C# Explained A  partial class  is useful to split the functionality of a particular class into multiple class files and all these files will be combined into one single class file when the application is compiled.   While working on large scale projects, multiple developers want to work on the same  class  file at the same time. To solve this problem, C# provides an ability to spread the functionality of a particular  class  into multiple  class  files using  partial   keyword .            In C#, we can use  partial   keyword  to split the definition of a particular  class ,  structure ,  interface  or a  method  over two or more source files.   Following is the example of splitting the definition of  Person class  into two class files, Person1.cs and Person2.cs .   First file (Perso...