C# shortcut or shorthand getter setter

后端 未结 4 1955
执念已碎
执念已碎 2020-12-29 01:31

Is there a short way to create the getter and setter in c#?

public string fname {get; set;} 

Is there short hand to generate {get; se

4条回答
  •  情话喂你
    2020-12-29 02:12

    When I type prop & TAB I get:

        public int MyProperty
        {
            get; set;
        }
    

    Is there a way to set it up so it's all on one line so it looks like:

    public int MyProperty { get; set;}

    UPDATE!!! I figured it out.

    Tools --> Options --> Text Editor --> C# --> Code Style --> Formatting --> Wrapping --> Put a checkmark in the "Leave block on a single line" option. It even uses the "get; set;" as an example.

提交回复
热议问题