Introduction
This will help developer to create property by setting the field name and datatype .
Background
This article will help developer to generate property by right click on field.
Using the code
public class Student
{
string Username;
public string _Username
{
get { return Username; }
set { Username = value; }
}
}
Above student class has a field called Username and we have set the property for them. Now in .NET instead of write these code we can generated by right click on field name .
Create a class and field then right click on field. click on Refactor then Encapsulated Field as show in the image.
Following window will popup.
Type the property name in property text box and click on ok
Following will be generated by .net IDE.
public string Username1
{
get { return Username; }
set { Username = value; }
}
Points of Interest
This option is really helpful for auto generating properties by creating the field type and setting the datatype.