开发者

What is the VB .Net equivalent of the C# shortcut test for something to be true or false? [duplicate]

This question already has answers here: Closed 12 years ago. 开发者_如何学运维

Possible Duplicate:

Is there a conditional ternary operator in VB.NET?

C# has a shortcut like this:

cmd.Parameters.Add(new SqlParameter("@p2", ((supplierID > 0) ? (object)supplierID : DBNull.Value)));

Just curious if VB .Net has something like that too?


cmd.Parameters.Add(New SqlParameter("@p2", (If((supplierID > 0), DirectCast(supplierID, Object), DBNull.Value))))


If((supplierID > 0, (object)supplierID, DBNull.Value)


You are describing a "ternary operator"

http://blog.dmbcllc.com/2007/11/29/the-ternary-operator-in-vbnet/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜