Saturday, 3 September 2011

c# 2.0 Partial Type

C# 2.0 introduces the concept of partial type definitions for classes, structs, and interfaces, as a means to break types in a program into multiple pieces to be stored in different source files for easier maintenance and development. This approach is particularly useful when the need arises to use nested types or provide interface implementation

Partial Type Attributes

Attributes on partial types are combined in an unspecified order so that they appear to all be defined on the given type

Example :

[Serializable]
Public Partial Class abc
{
int x;
}

[Dockable]
Public Partial Class abc
{
int y;
}
After Compliation the result would be

[Serializable,Dockable]
Public Partial Class abc
{
int x;
int y;
}

No comments:

Post a Comment