ITADN

[C#] C# 14 has evolved yet again

#4545Openbeautifulcoder 创建于 2026-05-08
C: Syntax
B
beautifulcodercommented
### What happened? In C# 14, they added record classes to specify is not a struct type. Also, you can type alias tuples. Sublime is simply showing syntax errors but this compiles correctly. ```csharp // record classes // A mutable record class. public record class C1 { public string? Name { get; set; } } // An immutable record class. public record class C2(string? Name); ``` Then this: ```csharp using Fruit = (string Name, int Number); // Aliasing a tuple type. ``` Here are screenshots of what I see. <img width="772" height="416" alt="Image" src="https://github.com/user-attachments/assets/c65e16b4-8c34-4596-aeff-f9187eda50ab" /> <img width="772" height="416" alt="Image" src="https://github.com/user-attachments/assets/4d01f844-9734-4b4e-9be6-869c4da52679" />
0 条评论