Resharper convert auto-property to full property

别等时光非礼了梦想. 提交于 2019-12-06 16:36:30

问题


I found the opposite here, but I need to frequently change from auto-property to full property - would it be possible to automate that (and with a shortcut perhaps):

From Auto-Property

public string FirstName { get; set; }

To Property with Backing Field

    private string _firstName;

    public string FirstName
    {
        get
        {
            return _firstName;
        }
        set
        {
            _firstName = value;
        }
    }

Obviously, I would then change the full property further ...


回答1:


Place your cursor on the property name, then wait a second or two. Press the Resharper hotkey sequence (Alt-Enter) and the second option should be "To property with backing field" which is what you want.

Alternatively, you can click the "hammer" icon in the left margin to get the option.




回答2:


To make it work (ALT-Enter) you must to configure resharper keyboard schema. VS -> Tools -> Options -> ReSharper -> General -> Options -> Keyboard and menus -> Resharper keyboard Schema -> Visual Studio



来源:https://stackoverflow.com/questions/10726918/resharper-convert-auto-property-to-full-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!