Hi friends....
I know concept of class but I want to know about partial class ? What is partial class and what is the use of partial class ? Please explain with an example in details ?
Thanks...
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jan 30, 2012, 6:29 PM
The compiler then combines the partial classes and compiles the combined class, just as if it had been written in a single file. It follows that the partial classes can't contain definitions of the same members.
Partial classes are commonly used to enable an automated tool to produce one partial class and a human programmer to produce another. A windows forms application developed in Visual Studio is a case in point.
Here's a simple example:
public partial class Person
{
public void DoSomething()
{
}
}
public partial class Person
{
public void DoSomethingElse()
{
}
}
The compiler will compile this as though it had been written:
public class Person
{
public void DoSomething()
{
}
public void DoSomethingElse()
{
}
}
Jignesh TrivediPosted Jan 30, 2012, 10:23 PM
.Net 2.0 provided us with new feature called partial classes. Using partial classes we can use multiple files to keep the code of same class.
In other word.
A class defined in two or more files is called a partial class. The keyword partial is used to define the class. When working on large projects, spreading a class over separate files allows multiple programmers to work on it simultaneously. During compile time all the partial class are compiled into one type only.
please refer
http://weblogs.asp.net/gunnarpeipman/archive/2008/06/08/c-and-partial-classes.aspx
hope this help.