【发布时间】:2017-03-29 23:23:35
【问题描述】:
我读到 on a blog 说 C# 7 将具有记录类型
class studentInfo(string StudentFName, string StudentMName, string StudentLName);
但是当我尝试它时,我得到了这些错误
CS0116 命名空间不能直接包含成员,例如字段或 方法
CS1022 类型或命名空间定义,或预期文件结尾
CS1514 { 预期的
这应该如何工作?
更新:这是 C# 9 的一个特性 https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/
【问题讨论】:
-
你引用的链接说这还没有实现
Update 22/07/2016: Records are probably not coming in C# 7, but will have to wait until the next version (supposedly c# 8) -
提供的C# 9 link 使用不再有效的
data class开发符号-as of .NET 5.0 RC 1 that has already been changed torecord。 Official (updated) docu also usesrecord.
标签: c# language-features c#-7.0