Posts

Showing posts with the label C# Partial Types

C# Partial Types

C# provides a concept to write source code in separate files and compile it as a single unit. This feature is called partial types and included in C# 2.0. The  partial  keyword is used to create partial types. It allows us to write partial  class, interface, struct and method  in two or more separate source files. All parts are combined when the application is compiled. Let's see an example. Here, we are creating a partial class that includes a depositeAmount() function in the  Customer.cs  file and a withdraw() function in the  Customer2.cs  file. Both functions are stored in separate file and combined when compiled. C# Partial Class Example // Customer.cs using  System;   namespace  CSharpFeatures   {      partial  class  Customer       {            // Deposit function     ...