Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在VisualStudio中自动实现具有单行属性的接口?_C#_Visual Studio 2015_Formatting - Fatal编程技术网

C# 如何在VisualStudio中自动实现具有单行属性的接口?

C# 如何在VisualStudio中自动实现具有单行属性的接口?,c#,visual-studio-2015,formatting,C#,Visual Studio 2015,Formatting,我正在关注Tim Corey关于C#的教程。当他自动实现一个接口(使用ctr+)时,所有属性都在一行上,如下所示: public class MyModel : IMyInterface { public string example1 { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public string example

我正在关注Tim Corey关于C#的教程。当他自动实现一个接口(使用ctr+)时,所有属性都在一行上,如下所示:

    public class MyModel : IMyInterface
{
    public string example1 { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
    public string example2 { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
}
但当我做同样的事情时,我得到了:

    public class MyModel : IMyInterface
{
    public string example1
    {
        get
        {
            throw new NotImplementedException();
        }

        set
        {
            throw new NotImplementedException();
        }
    }
    public string example2 { get; set; }
            {
        get
        {
            throw new NotImplementedException();
        }

        set
        {
            throw new NotImplementedException();
        }
    }
}
让我的代码看起来和指导老师一样会很好,这样就更容易理解教程了,而且我认为第二种格式看起来很混乱

是否有一个我可以设置的首选项设置,以便在单行上获取属性(如果它们被称为首选项)

我试图寻找重复的,但因为我是新来的,对C#方言不太确定,所以没有那么容易。

这是C#6的一个特性-


你一定要小心

您是否可能正在使用诸如ReSharper之类的工具。它们将钩住源代码生成并应用其自定义格式。如果是,请禁用ReSharper并重试。如果这个问题得到解决,你需要在ReSharper代码生成中做一些调整。你可以用JetBrains来做Resharper@Dainiel我没有使用resharper,但可能是讲师在使用。我会调查的。谢谢,你好。我目前正在做的项目是一个控制台应用程序。启用C#6的选项未显示。我试图创建一个新的Web应用程序项目,它出现在项目菜单中。有没有办法在控制台应用程序中启用它?