簡體   English   中英

自動列出課程的屬性

[英]Auto List out properties of a class

假設您有一堂課:

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

當您創建鮑勃的新實例時:

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?
}

有沒有一種方法可以自動寫出所有屬性,而不必知道要鍵入什么? 因此Visual Studio 2013可能最終會為您完成此操作,因此您知道要填寫什么:

   Bob bob = new Bob {
        Something = ,
        Something2 = ,
        Something3 =
    }

如果您按Ctrl-Space或任何使用Intellisense的快捷方式,Visual Studio自己的Intellisense或R#都會建議屬性。 該功能足夠智能,只能建議您尚未分配的內容。 這樣,您可以一個接一個地填充它們,直到不再出現智能感知。

當您以這種方式使用變量initialasition時,Visual Studio應該具有自動完成功能。

放置逗號時,按Enter鍵,它將列出其余屬性。

如果您使用CTRL + SPACE,它將給出所有屬性的列表

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM