Tips & Ticks by SAJJAD
C# partial Keyword
using System;
namespace ConsoleApplication
{
static class Program
{
static void Main()
{
User a = new User();
Console.WriteLine(User.Instance);
User b = new User();
Console.WriteLine(User.Instance);
Console.Read();
}
}
public enum Gender
{
Male,
Female
}
public partial class User
{
private Gender _gender;
public Gender Gender
{
get
{
return this._gender;
}
set
{
this._gender = value;
}
}
public User()
{
Instance++;
}
~User()
{
Instance--;
}
}
public partial class User
{
public static int Instance = 0;
public static readonly User Empty;
}
}
| Print article | This entry was posted by SAJJAD on October 25, 2009 at 10:07 pm, and is filed under C#, Language. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |