| Start | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Null conditional operator To avoid verbose null checking, the The old verbose syntax: Can be now replaced by the concise: The Normally you would have to write something like this: But with the |
||||||||||||||||||||
| String interpolation This new feature makes the string concatenation more readable. This syntax will be compiled to its equivalent Without string interpolation: With string interpolation: The two lines are equivalent and both get compiled to a call to As in String Interpolation is the preferred method over This will compile, but will cause a runtime error as the compiler does not check that the number of arguments match the placeholders. |
||||||||||||||||||||
| Read-Only Auto-Properties Read-only properties were always possible in VB.NET in this format: The new version of Visual Basic allows a short hand for the property declaration like so: The actual implementation that is generated by the compiler is exactly the same for both examples. The new method to write it is just a short hand. The compiler will still generate a private field with the format: |
||||||||||||||||||||
| NameOf operator The One of the use cases: The old syntax will expose the risk of renaming the variable and leaving the hard-coded string to the wrong value. With The The operator also uses the name of the reference that is typed in without resolving any name changing imports. For example: |
||||||||||||||||||||
| Multiline string literals VB now allows string literals that split over multiple lines. Old syntax: New syntax: |
||||||||||||||||||||
| Partial Modules and Interfaces Similar to partial classes the new version of Visual Basic is now able to handle partial modules and partial interfaces. The syntax and behaviour is exactly the same as it would be for partial classes. A partial module example: And a partial interface: Just like for partial classes the definitions for the partial modules and interfaces have to be located in the same namespace and the same assembly. This is because the partial parts of the modules and interfaces are merged during the compilation and the compiled assembly does not contain any indication that the original definition of the module or interface was split. |
||||||||||||||||||||
| Comments after implicit line continuation VB 14.0 introduces the ability to add comments after implicit line continuation. |
||||||||||||||||||||
| #Region directive improvements #Region directive can now be placed inside methods and can even span over methods, classes and modules. |
||||||||||||||||||||
| Exception handling During coding, unexpected errors do arise frequently enough, which requires debugging and testing. But sometimes the errors are indeed expected and to bypass it, there is the To manage an error correctly, the code is put into a And in case of exception, we have the possibility to The In case we need to pop-out of the clock, there is the The syntax is simple; where only the Coming to the exception, there are different type of exception that can be caught. They are ready made exceptions available from the .Net Framework, as below;
|
Read Article
https://develop.horje.com/learn/1434/reference