开发者

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

开发者 https://www.devze.com 2023-01-20 15:13 出处:网络
This question already has answers here: Closed 12 years ago. 开发者_如何学运维 Possible 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

精彩评论

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