2017-06-26 14 views
2

更多的是爲什麼,而不是如何,但這是如何可能的,因爲我在印象之下所有構造函數都需要一個代碼塊 - 即使它沒有任何內容?任何人都可以解釋這個沒有代碼體的類構造函數嗎?

以下代碼是直接從類定義採取

AspNet.Identity.EntityFramework.IdentityUser

的構造爲IdentityUser類不具有在定義一個代碼塊?有人可以解釋嗎?

public class IdentityUser : IdentityUser<string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>, IUser, IUser<string> 
{ 
    // 
    // Summary: 
    //  Constructor which creates a new Guid for the Id 
    public IdentityUser(); 

    // 
    // Summary: 
    //  Constructor that takes a userName 
    public IdentityUser(string userName); 
} 
+0

請參閱:https://stackoverflow.com/questions/22409520/bodyless-constructor-in-non-abstract-c-sharp-class – jlavallet

回答

5

這是從彙編元數據中由Visual Studio的Go To Definition服務生成的僞代碼。

這不是真正的代碼,並不會真正編譯。

您可以在「文件」頂部的註釋中看到此內容。

相關問題