Casting Y or N to bool C#

前端 未结 10 2218
故里飘歌
故里飘歌 2021-02-07 05:46

Just for neatness sake I was wondering, whether it\'s possible to cast Y or N to a bool? Something like this;

bool theanswer = Convert.ToBoolean(input);
         


        
10条回答
  •  广开言路
    2021-02-07 06:27

    As suggested by Jon, there's nothing inbuilt like this. The answer posted by John gives you a correct way of doing. Just for more clarification, you can visit:

    http://msdn.microsoft.com/en-us/library/86hw82a3.aspxlink text

提交回复
热议问题