2013-04-12 83 views
-1

我从C#转换应用到VB,但我被困在这条线:转换此C#代码到VB

byte[] picData = sdr2["foto"] as byte[] ?? null; 

任何一个可以帮助我把它转换。

在此先感谢

+3

什么是'点? null'? – MarcinJuraszek

+0

你的问题到底是什么? '?? null“似乎是超级流利的,其余的都很简单。 – nvoigt

+1

哇..合并运算符为null,用于返回null! ! – V4Vendetta

回答

0
Dim picData As Byte() = If(TryCast(sdr2("foto"), Byte()), Nothing) 

对于这样一个转换,你可以依靠网络转换器过多做一个(相对)体面的工作。

退房http://www.developerfusion.com/tools/convert/csharp-to-vb/或任何其他人,有一个谷歌在它。

但要注意,你的空合并运算状态,在这种情况下,如果sdr2["foto"] as byte[]回报null,然后返回null ......你可能想解决这个问题;-)

+0

谢谢你的答案 – user1891628

0

尝试this

Dim picData As Byte() = If(TryCast(sdr2("foto"), Byte()), Nothing) 
0

这里是一个useful tool翻译VB < - > C#

Dim picData As Byte() = If(TryCast(sdr2("foto"), Byte()), Nothing) 

正如MarcinJuraszek首先指出,?? null这里并不意味着什么,所以你应该使用:

Dim picData As Byte() = TryCast(sdr2("foto"), Byte())