Conditional operator for String.Format in VB.NET?

steva
steva used Ask the Experts™
on
Is there anything in VB.NET that would let me do something like below?

       Dim mul As Boolean
       Response.Write(String.Format("To get the answer {0} 20 by 5", mul? "multiply" : "divide"))

Here the {0} parameter should become "multiply" if mul is true and "divide" if mul is false.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
Commented:
Try this:

Dim mul As Boolean
Response.Write(String.Format("To get the answer {0} 20 by 5", IIf(mul, "multiply", "divide")))

Open in new window

Author

Commented:
Yep.  That works.  Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial