InterviewSolution
| 1. |
What Is A Partial Class. Give An Example? |
|
Answer» A partial class is a class whose definition is present in 2 or more files. Each source file contains a section of the class, and all PARTS are combined when the application is compiled. To SPLIT a class definition, use the partial keyword as shown in the example below. Student class is split into 2 parts. The first part defines the study() method and the second part defines the Play() method. When we compile this program both the parts will be combined and compiled. NOTE that both the parts uses partial keyword and public access modifier. using System; It is very important to keep the following points in MIND when creating partial classes. A partial class is a class whose definition is present in 2 or more files. Each source file contains a section of the class, and all parts are combined when the application is compiled. To split a class definition, use the partial keyword as shown in the example below. Student class is split into 2 parts. The first part defines the study() method and the second part defines the Play() method. When we compile this program both the parts will be combined and compiled. Note that both the parts uses partial keyword and public access modifier. using System; It is very important to keep the following points in mind when creating partial classes. |
|