c# - 如何防止生成的接口(interface)实现使用类型别名?

标签 c# visual-studio visual-studio-2012

我目前正在使用 Visual Studio(特别是 2012 Express)。我有一个接口(interface)已经定义如下:

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

如果我有一个空类:

class MyClass : IMyInterface
{
}

然后我右键单击IMyInterface,我可以选择“Implement Interface”。当我这样做时,自动生成的代码会产生以下内容:

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

我的问题是,有没有办法让我自动生成以下内容:

    public String Data

代替:

    public string Data

?

最佳答案

没有办法做到这一点。它被硬编码为尽可能使用内置别名。

关于c# - 如何防止生成的接口(interface)实现使用类型别名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16127308/

相关文章:

c - 非常简单的程序可以在 Dev C++ 中编译,但不能在 Visual Studio 中编译

SQL 和 Visual Studios - 传递变量

c# - 将一个表达式转换为另一个表达式

c# 相当于nodejs代码

visual-studio - Visual Studio 2013 中的 Office 2016 加载项开发

python - IronPython + Wpf 上的按钮单击事件

c# - 从 LINQpad 转移到合适的 Visual Studio 项目?

c# - 按回车键时在文本框上执行命令

c# - 使用 C# 配置 Wifi 设置

visual-studio-2012 - System.Windows.ni.dll 是什么?