New VB11 Features
A preview of some of the new features coming in VB11, which you can experiment with via the VS11 Developer Preview
The New Features
A preview of some of the new features coming in VB11, which you can experiment with via the VS11 Developer Preview
The New Features
- Async & Await
This will be the major feature of VB11 asynchronous method supported directly by the language.
Module Module1 Sub Main Dim SourceCode = GetSourceCode() Console.WriteLine(SourceCode) End Sub Public Async Function GetSourceCode() As Task(Of String) Return Await (New Net.WebClient).DownloadStringTaskAsync("www.dreamincode.net") End Function End Module
The infrastructure used in the Async & Await enables VB.net to have a Yield keyword like c#. This allows us to use Iterators.
- Iterators
You can implement Iterator various ways, through the use of the Yield keyword
- Functions
Public Iterator Function OneToHundred() As IEnumerable(Of Integer) For x = 1 To 100 Yield x Next End Function
- Lambdas
Dim numbers_1_To_100 = Iterator Function() For x = 1 To 100 Yield x Next End Function
- Property (Strange but completes the list.)
Public ReadOnly Iterator Property Strange() As IEnumerable(Of Integer) Get For x = 1 To 100 Yield x Next End Get End Property
- Iterator Lambdas (VB.net only)
Dim numbers_1_To_100 = Iterator Function() For x = 1 To 100 Yield x Next End Function
- Functions
- Namespace Global.
Usually everything you write inside your project is enclosed inside a base namespace (typically the name of the project.) Sometime there situations where you need "escape" the behavior
Namespace Global.Numbers <HideModuleName> Public Module Numbers Public Function Naturals() As IEnumerable(Of Integer) Return (Iterator Function() Dim x = 0 While x < Integer.MaxValue Threading.Interlocked.Increment(x) Yield x End While Yield Integer.MaxValue End Function)() End Function End Module End Namespace
Which can, along side Iterators let me write a single function (above) the returns an IEnumerable containing the natural integer numbers (Whole Number starting from 1, up to the Integer.MaxValue)
Imports Numbers Module Module1 Sub Main() Dim Total = Naturals.Take(100).Where(Function(x) (x Mod 3) = 0 OrElse (x Mod 5 = 0)).Sum End Sub
7 Comments On This Entry
Page 1 of 1
Tryparse
14 October 2011 - 07:35 AM
Thanks for the preview ... I'm still waiting for our shop to upgrade to .Net 4
Yo!
14 October 2011 - 12:46 PM
It's just a small thing but I like that they have the ribon control now
Curtis Rutland
14 October 2011 - 02:54 PM
I don't think Iterator Properties are all that strange. Properties are just fancy groups of specific methods. If there's such thing as an iterator method, why not an iterator property?
Yo!
14 October 2011 - 09:37 PM
Sorry, I had read somewhere that the ribbon control was a new control added in but I just installed the Preview and noticed that it wasn't really there.
Sorry to mislead you.
Sorry to mislead you.
Page 1 of 1
|
|



7 Comments








|