VB.NET相当于C#“As”
C# As关键字的VB.NET中的等效内容如下所示?
var x = y as String; if (x == null) ...
这是TryCast:
Dim x As String = TryCast(y, String) If x Is Nothing Then ...
Trycast就是你要找的东西。
Dim x = TryCast(y, String)
TryCast:
Dim x = TryCast(y, String) if (x Is Nothing) ...
Dim x = TryCast(y,[String])
干得好:
C#代码:
var x = y as String; if (x == null) ...
VB.NET等效:
Dim x = TryCast(y, String) If (x Is Nothing) ...
Dim x = TryCast(y, [String])
来自: http : //www.developerfusion.com/tools/convert/csharp-to-vb/