Is there a short way to create the getter and setter in c#?
public string fname {get; set;}
Is there short hand to generate {get; se
If you just want the getter and setter, as orignally asked for, you could also create a custom snippet:
GetSet
Inserts getter/setter shorthand code
gs
Save the above as a .snippet in your snippets folder. Typing 'gs' and pressing Tab will insert { get; set;}
and move to the end of the line.
In VS Code, this would be a custom user snippet in your csharp.json
file:
"Getter Setter": {
"prefix": "gs",
"body": [
"\\{ get; set; \\}",
"$1"
],
"description": "Insert shorthand autoproperties"
}
Either of these examples could easily be modified/duplicated to also do { get; }
(use a readonly
backing field) or { get; private set; }