What is the VB .Net equivalent of the C# shortcut test for something to be true or false? [duplicate]
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/
精彩评论