VB expression trees – coalesce operator

Hey there! In this post, I’ll continue describing some of the things that are interesting about the VB compiler, especially related to expression trees and the consumption of expression trees in your LINQ provider. Again, this may not be too interesting if you aren’t writing a LINQ provider, but I hope you read on anyway…

4

Checking generic parameters for Nothing/null

Consider the following code fragment: Module Module1 Sub Foo(Of T)(ByVal x As T) If x Is Nothing Then End If End Sub Sub Main() Foo(10) End SubEnd Module The first thing you might ask is : “hey, how come the compiler allows me to check for Nothing? Isn’t that a reference comparison? There is no…

1