Partial type - Your Art History Reference Guide!

ArtHistoryClub Information Site on Partial type Art History Art History Search        Art History Browse             News        Gallery        Forums        Articles        Weblinks        welcome to our free resource site for all art history lovers!

Partial type

In computing, a partial type is a data type definition which spans multiple source code files. In object orientated programming this may be necessary for a variety of reasons: performance and cost can often prohibit the use of several separate classes; the use of code generating tools is increasing, and it is convenient to separate machine generated code from code written by the programmer.

Partial types are a feature of the C# 2.0 language. The syntax for creating a partial class definition is as follows:

SourceFile1.cs

public partial class ExampleClass
{
   public void SomeFunction()
   {
       // ...
   }
}

SourceFile2.cs

public partial class ExampleClass
{
   public void SomeOtherFunction()
   {
       // ...
   }
}

In C# versions before 2.0, this would cause a compiler error because the same class appears to be defined twice (and also because of the partial keyword). In C# 2.0 this is treated as a single class definition. Other new features of C# 2.0 include anonymous methods , iterators and generics (similar to templates in C++).

The use of partial classes has no effect on generated code (unless editor meta-data is emitted).

Last updated: 10-22-2005 18:38:05
Last updated: 06-05-2009 13:38:31
The contents of this article are licensed from Wikipedia.org under the
GNU Free Documentation License. See original document.

See more unique gifts by PositiveDesigns
Art History Search | Art History Browse | Contact | Legal info