문제

Say you have a class:

class Bob
{
    public int Something { get;set; }
    public int Something2 { get; set; }
    public int Something3 { get; set; }
}

when you go to create a new instance of Bob:

Bob bob = new Bob {
    Something = 1,
    // Is there a way to automatically write out all properties rather than having to know what they were to type them out?
}

Is there a way to automatically write out all properties rather than having to know what they were to type them out? so Visual Studio 2013 might end up doing this for you so you know what to fill out:

   Bob bob = new Bob {
        Something = ,
        Something2 = ,
        Something3 =
    }
도움이 되었습니까?

해결책

Either Visual Studios own Intellisense or R# will suggest the properties if you press Ctrl-Space or whatever your shortcut to Intellisense is. The feature is intelligent enough to only suggest those you did not already assign. That way you can fill them one after another until the intellisense does not pop up any more.

다른 팁

Visual Studio should have autocomplete when you use variable initialasition that way.

when you place the comma, hit enter and it will list the remaining properties.

If you use CTRL + SPACE it will give a list of ALL properties

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top