Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expression-bodied members for VB.NET?

Does VB.NET support expression-bodied members? So far, it seems to have everything in c# like null conditionals, nameof, interpolated strings, bodiless auto properties accessible only via ctor, etc.

In c#, the syntax is:

string FullName => FirstName + " " + LastName;

How can I achieve this in VB.NET?

like image 351
oscilatingcretin Avatar asked Jun 13 '16 12:06

oscilatingcretin


1 Answers

No, they are not currently supported in VB 14, only C# 6.

According to the table on the roslyn Github Wiki Languages features in C# 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    |
+---------------------------------------------------------------+--------+--------+
like image 181
RB. Avatar answered Sep 18 '22 17:09

RB.