Monday, March 15, 2010

VB.Net equivalent of C# “As”

Here is an equivalance of the as of C# to VB programmers.

in C# you do this:

var x = y as String;
if (x == null) ...

in VB you do this :

Dim x As String = TryCast(y, String)
If x Is Nothing Then ...

meaning  "as" = "TryCast"



No comments: