What is Partial Class?

Partial Keyword indicates that class, structure or interface devided in more than 1 part with in same namespace
At compilet time all parts are mearged in to single.
When some large class or many people working on the same project and in multiple files
this is used
For example in one project 2 people working in same task, so both needs that class to change, so that single file is not possible. There is a chance to overwrite on without Visual Source Safe and in with another can not work on that file. so class is devided in to two parts with partial in two files.
//User1.cs
  public partial class Sample
  {
  Int a;
  }
//User2.cs
  public partial class Sample
  {
  public void changeA(int val) { a = val; }
  }

0 comments:

Post a Comment