C 3.0 Features Without Visual Basic 9.0 Counterparts


C# 3.0 Features Without Visual Basic 9.0 Counterparts

C# 3.0 has some features that do not have an equivalent in Visual Basic 9.0. These features are the yield keyword and anonymous methods. Neither of these features is fundamental to supporting LINQ, even if they are useful in many situations that are common when writing code that uses LINQ.

The yield Keyword

Visual Basic 9.0 does not have a feature that corresponds to the C# 2.0 yield keyword. You can implement iterators in Visual Basic 9.0 by using an iterator design pattern. Remember that yield does not require support from the CLR. It is implemented by the compiler that generates the code necessary for implementing the iterator.

More Info 

For more information about closures, see the section called “Closures,” earlier in this chapter.

Anonymous Methods

Anonymous methods are not available in Visual Basic 9.0 as a stand-alone feature, but sometimes lambda expressions can be used as a substitute. Closures for lambda expressions are generated by the compiler in a way that is similar to that used by the C# compiler with anonymous methods. However, lambda expressions cannot replace anonymous delegates in every situation.




Introducing Microsoft LINQ
Introducing MicrosoftВ® LINQ
ISBN: 0735623910
EAN: 2147483647
Year: 2007
Pages: 78

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net