What is the VB .Net equivalent of the C# shortcut test for something to be true or false?
本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
Is there a conditional ternary operator in VB.NET?
C有这样的快捷方式:
1 | cmd.Parameters.Add(new SqlParameter("@p2", ((supplierID > 0) ? (object)supplierID : DBNull.Value))); |
只是好奇VB.NET是否也有类似的东西?
在vb.net中有条件三元运算符吗?
1 | cmd.Parameters.Add(New SqlParameter("@p2", (If((supplierID > 0), DirectCast(supplierID, Object), DBNull.Value)))) |
1 | If((supplierID > 0, (object)supplierID, DBNull.Value) |
你在描述一个"三元运算符"
http://blog.dmbclc.com/2007/11/29/the-ternary-operator-in-vbnet/