Partial Class in C#
It is possible to split the definition of a class or a struct, or an interface over two or more source files.
Each source file contains a section of the class definition, and all parts are combined when the application is compiled.
There are several situations when splitting a class definition is desirable:
When working on large projects, spreading a class over separate files allows multiple programmers to work on it simultaneously.
When working with automatically generated source, code can be added to the class without having to recreate the source file.
Visual Studio uses this approach when creating Windows Forms, Web Service wrapper code, and so on.
You can create code that uses these classes without having to edit the file created by Visual Studio.
Example for Partial Class
public partial class Employee
{
public void DoWork()
{
}
}
public partial class Employee
{
public void GoToLunch()
{
}
}
At compile time, attributes of partial-type definitions are merged. For example, the following declarations:
Dotnet, DotnetCore, Azure, C#,VB.net, Sql Server, WCF, MVC ,Linq, Javascript and Jquery
Subscribe to:
Post Comments (Atom)
Implementing OAuth validation in a Web API
I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...
-
ViewBag, ViewData, TempData and View State in MVC ASP.NET MVC offers us three options ViewData, ViewBag and TempData for passing data from...
-
// Export Datatable to Excel in C# Windows application using System; using System.Data; using System.IO; using System.Windows.Forms; ...
No comments:
Post a Comment
Comments Welcome