首页 > 解决方案 > 将参数传递给 C# 8 中的类声明

问题描述

从 C# 8 开始,我们可以执行以下操作:

public class MyClass(int a)
{
    // note, this is NOT the constructor, but the class declaration
}

这是如何运作的?

在 C#7 中,它被标记为实验性功能;但我找不到有关它的文档。是否仍被认为是 C# 8 的实验性版本?

我看到了这个:

在此处输入图像描述

标签: c#rider

解决方案


推荐阅读