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.
![Image 1](/KB/dotnet/656969/Screen1.jpg)
Following window will popup.
![Image 2](data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==)
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.
I have 10+ years of experience in IT industry with a wide range of experience in analysis, design, development, implementation of Web Based Applications & Client Server Applications in various Microsoft related Technologies.