what is partial keyword in c# [Resolved]

Posted by Nagukothapalli under C# on 11/9/2012 | Points: 10 | Views : 1638 | Status : [Member] | Replies : 2
where we use partial keyword in c# and what is the advantage of partial keyword




Responses

Posted by: M_Imranbest on: 11/10/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,
The biggest use of partial classes is make life easier.
Partial classes is a new concept in C# 2.0.
Partial class means, a single class is split into multiple classes across multiple files with same signature. When compiler will compile the class file, it makes into single class.

The advantage of this is each developer can work on individual files and at the time of compilation, all the partail classes will be run as one class.It is easy to maintain and also find out where the error is using partial classes.

This provides a very clean framework for separation of concerns.

Example:

public partial class Employee
{
public void DoWork()
{
}
}

public partial class Employee
{
public void GoToLunch()
{
}
}

For more info link : http://msdn.microsoft.com/en-us/library/wa80x488(v=vs.80).aspx

Thanks & Regards;
M Imran Ansari


Thanks & Regards;
Muhammad Imran Ansari

Nagukothapalli, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saratvaddilli on: 11/10/2012 [Member] [MVP] Bronze | Points: 50

Up
0
Down

Resolved
simply about partial keyword
in the best practices of coding we should write only 1000 lines of code in one class file .
if we had a code more than 1000 codes of lines then we will write them into partial keyword with the same class name at the compile time they become as unique i.e after compilation they will become as single class

Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

Nagukothapalli, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response