Shortcut to create properties in Visual Studio?

后端 未结 16 1912
暖寄归人
暖寄归人 2020-12-02 03:42

I have seen some people creating properties in C# really fast, but how did they do it?

What shortcuts are available in Visual Studio (currently using Visual Stu

16条回答
  •  清歌不尽
    2020-12-02 04:20

    What I liked in the IDE was that I was able to write a few variables like:

        private int id;
        private string name;
        private string version;
        private string description;
        private string status;
        private string symbol;
    

    Notice, that the variable names start with small letters, and then select the whole block, and press Ctrl+R, Ctrl+E, Apply. The properties are generated with the capital letter:

        public int Id
        {
            get
            {
                return id;
            }
    
            set
            {
                id = value;
            }
        }
    

    etc.

提交回复
热议问题