2

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?

0

3 Answers 3

1
cmd.Parameters.Add(New SqlParameter("@p2", (If((supplierID > 0), DirectCast(supplierID, Object), DBNull.Value))))
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

0

You are describing a "ternary operator"

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

1 Comment

Yes, it's a ternary operator, but it's actually called the IF operator. blogs.msdn.com/b/vbteam/archive/2008/03/11/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.