简体   繁体   中英

what is the shortcut to populate constructor variables in Visual Studio 2013?

I was watching a tutorial from pluralsight about asp.net MVC 5 framework And I saw something wonderful to speed up my coding. I googled it and i didn't find it. perhaps I didn't use right key words. any way, this is what i saw :

1- he was creating a constructor for Controller and the code was just like this :

 public class HomeController : Controller
   {

    public HomeController(ApplicationDbContext context)
    {

    }

and the cursor was on the word "context" , he used a shortcut and sudnly in no time code became this :

public class HomeController : Controller
{
    private readonly ApplicationDbContext _context;

    public HomeController(ApplicationDbContext context )
    {
        _context = context;
    }

what shortcut he used to create properties like this ? anyone knows how I can do this?

That is from ReSharper. It's the Introduce Field command. ReSharper is an excellent tool for productivity and consistency. See more information here about that feature of ReSharper: https://www.jetbrains.com/resharper/webhelp80/Refactorings__Introduce_Field.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM