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
        private string _name;
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public void CheckName()
        {
            if (_name == "Dark Side of the Moon")
                Console.WriteLine("Awesome");
        }

Place your cursor on the Name property and…

Press <Alt-Enter>

image

After
        public string Name { get; set; }

        public void CheckName()
        {
            if (Name == "Dark Side of the Moon")
                Console.WriteLine("Awesome");
        }

Happy coding!

 

del.icio.us Tags: ,

Dew Drop – July 5, 2011

Top Links

 

.NET / Visual Studio

 

Web Development

 

Design / Methodology / Testing

 

Silverlight / WPF / Windows Phone

 

Podcasts / Screencasts / Videos

 

Database

 

SharePoint

 

Miscellaneous

 

More Link Collections

 

The Geek Shelf

Essential Windows Azure: Architecting and Developing Applications for the Cloud (Developer’s Library) by Kevin Hoffman

 

 

Dew Drop – June 17, 2010

Jump to: Top Links | .NET / Visual Studio | Web Development | Design / Methodology / Testing | Silverlight / WPF / Windows Phone | Podcasts / Screencasts / Videos | Community / Events | Database | SharePoint | Miscellaneous | More Link Collections | The Geek Shelf

 

Top Links

 

.NET / Visual Studio

 

Web Development

 

Design / Methodology / Testing

 

Silverlight / WPF / Windows Phone

 

Podcasts / Screencasts / Videos

 

Community / Events

 

Database

 

SharePoint

 

Miscellaneous

 

More Link Collections

 

The Geek Shelf

ASP.NET MVC 2 in Action by Jeffrey Palermo