I've been using a new trick on my courses as of late that I've been getting some questions about. I figured I'd just blog about it to share the trick.
The trick in question is taking a constructor parameter and storing it in a class field. Most of it is just refactoring, but there is a way to customize what it looks like.
I like to use factoring to build up my code as I write. I'm not a Resharper guy, but i'll use it as much as I can. I just don't like to re-setup Resharper on every install. I'm basically lazy.
If you've used refactoring before, then this animation won't surprise you. You can see here that I'm:
This works 'out of the box', but customizing it to be the style I like was harder to figure out. You see, I prefer the _ prefix and camel-casing. You might prefer some other style (and out of the box it's a little different). To customize what is generated, you need to look in the
You'll find a lot of the refactoring options in the Code Style part of the Text Editor/C# section. Neat, huh?
What do you think?
|Building a Web App with ASP.NET Core, MVC6, EF Core, Bootstrap and Angular (updated for 2.0)|
|Using Visual Studio Code for ASP.NET Core Projects (new)|
|Implementing and Securing an API with ASP.NET Core|
|Building a Web App with ASP.NET Core, MVC6, EF Core and AngularJS|
|Building a Web App with ASP.NET5, MVC6, EF7, and AngularJS (Retired)|
|Best Practices in ASP.NET: Entities, Validation, and View Models|
|Front-End Web Development Quick Start|
|Lessons from Real World .NET Code Reviews|
|Node.js for .NET Developers|
|Application Name||WilderBlog||Environment Name||Production|
|Application Ver||22.214.171.124||Runtime Framework||.NETCoreApp,Version=v2.0|
|App Path||D:\home\site\wwwroot\||Runtime Version||.NET Core 4.6.25815.02|
|Operating System||Microsoft Windows 6.2.9200||Runtime Arch||X86|