What is the equivalent in VB.NET of the C# As keyword, as in the following?
var x = y as String; if (x == null) ...
Dim x = TryCast(y, [String])
From: http://www.developerfusion.com/tools/convert/csharp-to-vb/
TryCast:
Dim x = TryCast(y, String) if (x Is Nothing) ...
It is TryCast:
Dim x As String = TryCast(y, String) If x Is Nothing Then ...
Trycast is what you're looking for.
Dim x = TryCast(y, String)
Here you go:
C# code:
VB.NET equivalent:
Dim x = TryCast(y, String) If (x Is Nothing) ...
You can use it with ?:
?
TryCast(item, String)?.Substring(10)
It allows you to manage nullable without if :)
if