Can .NET convert "Yes" & "No" to boolean without If?

Posted by hawbsl on Stack Overflow See other posts from Stack Overflow or by hawbsl
Published on 2010-05-20T10:05:39Z Indexed on 2010/05/20 10:20 UTC
Read the original article Hit count: 263

Filed under:
|
|

You would think there would be a way using DirectCast, TryCast, CType etc but all of them seem to choke on it e.g.:

CType("Yes", Boolean)

You get:

System.InvalidCastException - Conversion from string "Yes" to type 'Boolean' is not valid.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about casting