Is there a way to generate getters and setters in Visual Studio? I'm trying with Alt + R, F and i get this:
public String Denomination
{
get { return denomination; }
set { denomination = value; }
}
and what I want is this:
public String getDenomination()
{
return Denomination;
}
public void setDenomination(String Denomination)
{
this.Denomination = Denomination;
}
is there a way to do that?
You can use the prop
code snippet to create automatic properties.
Type prop
, and press Tab
. You can then change the Type and name of the property.
In your simple case, where no additional logic is required, there's no needed for backing fields.
I do not think there is a built in way to do it out of the box with Visual Studio, but they do provide a way for you to add that feature.
What you will need to do is create a Code Snippet that creates those two methods and add the snippet to your %USERPROFILE%\Documents\Visual Studio 2013\Code Snippets\Visual C#\My Code Snippets
folder. Once you do that you will be able to type the snippet name in and hit tab
and it will fill in the text you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With