VB.NET 支持表达式主体成员吗?到目前为止,它似乎拥有 C# 中的所有内容,例如 null 条件、nameof、内插字符串、只能通过 ctor 访问的无实体自动属性等。
在 C# 中,语法为:
string FullName => FirstName + " " + LastName;
我如何在 VB.NET 中实现这一目标?
不,目前 VB 14 不支持它们,仅 C# 6 支持。
根据 roslyn Github Wiki 上的表格C# 6 和 VB 14 中的语言功能 https://github.com/dotnet/roslyn/wiki/Languages-features-in-C%23-6-and-VB-14:
+---------------------------------------------------------------+--------+--------+
| Feature | C# 6 | VB 14 |
+---------------------------------------------------------------+--------+--------+
| Auto-property initializers | Added | Exists |
| Read-only auto-properties | Added | Added |
| Ctor assignment to getter-only autoprops | Added | Added |
| Static imports | Added | Exists |
| Index initializer | Added | No |
| Await in catch/finally | Added | No |
| Exception filters | Added | Exists |
| Partial modules | N/A | Added |
| Partial interfaces | Exists | Added |
| Multiline string literals | Exists | Added |
| Year-first date literals | N/A | Added |
| Comments after implicit line continuation | N/A | Added |
| TypeOf ... IsNot ... | N/A | Added |
| Expression-bodied members | Added | No |
| Null-conditional operators | Added | Added |
| String interpolation | Added | Added |
| nameof operator | Added | Added |
| #pragma | Added | Added |
| Smart name resolution | N/A | Added |
| Read-write props can implement read-only interface properties | Exists | Added |
| #Region inside methods | Exists | Added |
| Overloads inferred from Overrides | N/A | Added |
| CObj in attributes | Exists | Added |
| CRef and parameter name | Exists | Added |
| Extension Add in collection initializers | Added | Exists |
| Improved overload resolution | Added | N/A |
+---------------------------------------------------------------+--------+--------+
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)