Last week at the Professional Developers Conference, we made a number of very exciting announcements regarding the future of Visual Basic. Here is the list of VB 2010 features we’ve announced:
- Collection Initializers. Initialize collections in fewer lines of code! Use the “From” keyword followed by a list, rather than successive calls to the Add method.
- Dim y As New List(Of String) From {“hello”, “world”}
- Dim x As New Dictionary(Of String, Integer) From {{“hello”, 1}, {“world”, 2}}
- Array literals. Express arrays more concisely. Whereas before you used to have to write New Integer() {1,2,3}, now you can just write {1,2,3}. Leave it to the compiler to infer the type of the items in the array! This can be very convenient wherever you use arrays.
- 2D array: {{1,0},{0,1}}
- Jagged array: {({1,2,3,4}),({1,2})}
- Statement lambdas. Visual Basic 2008 enabled lambda expressions. Now you can write multi-line lambda subs or functions as well!
- Define a Sub or Function anywhere a delegate is expected.
- Auto-implemented properties. Eliminate 8 out of 9 of the lines you write for boiler-plate VB properties today!
- Expanded property syntax:
Private m_Id As Integer
Public Property Id() As Integer
Get
Return m_Id
End Get
Set(ByVal value As Integer)
m_Id = value
End Set
End Property - Auto-property syntax, new in VB 2010:
Public Property Id() As Integer - Auto-property syntax, with an initializer:
Public Property Id() As Integer = 100 - Removal of the line continuation character. Underscores are no longer needed in the most common line continuation scenarios. Can you believe it?!?!
- Attributes, argument lists, parameter lists, queries, and binary operators are some of the most common scenarios for an underscore. In VB 2010, you can now write these lines underscore-free!
- What are we to do with all those unused underscores? Check out http://www.unemployedunderscores.com
- Generic co- and contra- variance. Code that used to generate errors will now work error-free! See Lucian Wischik’s blog posts on this new feature, which has been enabled by CLR 4.0.
- http://blogs.msdn.com/vbteam/archive/2008/08/07/co-and-contra-variance-lucian-wischik.aspx
- http://blogs.msdn.com/lucian/archive/2008/10/02/co-and-contra-variance-how-do-i-convert-a-list-of-apple-into-a-list-of-fruit.aspx
- No PIA. Deploy your Office applications without the bulky primary interop assemblies! VB 2010 will embed the Office types your application depends on, right into the app itself. No more need to deploy large PIAs.
- Interop with dynamic languages. VB 2010 offers improved support to interoperate with dynamic languages. Dynamic and static languages each have their own benefits, libraries, and particular scenarios for which they are better suited. With VB 2010, you no longer need to choose just one! You can use dynamic languages directly from VB.Net as needed.
So many exciting features to look forward to! Stay tuned for more blog posts and videos which illustrate these features in more detail.
0 comments
Be the first to start the discussion.