interviews.dotnetthread.com

↑ Grab this Headline Animator

Tuesday, January 13, 2009

Automatic Property (without backfield) in C# 3.0

In C# 3.0 (Shipped with Visual studio 2008) we have a new feature called Automatic Property through which we can declare a property with empty get and set accessors. The compilor CLR will take care of automatically generating backfield(private Variable ex:_Name) at runtime.


//Conventional Way
private string _Name;
public string Name
{
get { return _Name;}
set { _Name = value; }
}

//Automatic Property
public int Name
{
get;
set;
}

Any ways if you want to impliment your own filter logic you can always use Conventional way having back field.

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles