簡體   English   中英

如何防止生成的接口實現使用類型別名?

[英]How can I prevent the generated implementation of an interface from using a type alias?

我目前正在使用Visual Studio(特別是2012 Express)。 我有一個接口已經定義如下:

interface IMyInterface
{
    public String Data { get; set; }
}

如果我有一個空類:

class MyClass : IMyInterface
{
}

我右鍵單擊IMyInterface ,我可以選擇“實現接口”。 當我這樣做時,自動生成的代碼產生以下內容:

class MyClass : IMyInterface
{
    public string Data
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }
}

我的問題是,有沒有辦法可以自動生成以下內容:

    public String Data

代替:

    public string Data

沒有辦法做到這一點。 在可能的情況下使用內置別名是硬編碼的。

暫無
暫無

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

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