C# + ReSharper = Awesome: Tip #1 – To Automatic Property
This is the first in a series of quick how-to posts on ReSharper. I love ReSharper. It is a tool that I use every day and don’t really realize how much I rely on it until I use a machine without ReSharper installed.
Tip #1 – To Automatic Property
Use: If a public property does not contain any logic, it can be converted to an auto-property, removing the corresponding private field and replacing usages of the private field.
Before
1: private string _name;
2: public string Name
3: {
4: get { return _name; }
5: set { _name = value; }
6: }
7:
8: public void CheckName()
9: {
10: if (_name == "Dark Side of the Moon")
11: Console.WriteLine("Awesome");
12: }
Place your cursor on the Name property and…
Press <Alt-Enter>
After
1: public string Name { get; set; }
2:
3: public void CheckName()
4: {
5: if (Name == "Dark Side of the Moon")
6: Console.WriteLine("Awesome");
7: }
Happy coding!







What’s even more awesome is that this feature participates in the code cleanup profile options. Ctrl + E, F is my friend