C# How to put variable into bool | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C# How to put variable into bool

Hello... I think its very simple but can't find it anywhere so i will ask here... How put a variable bool false/true into code and declare if its true or false. It can be with Console.ReadLine()? Because when i use it its error in convert

28th May 2020, 10:39 AM
Matthew
Matthew - avatar
3 Answers
+ 1
Console.ReadLine() return string value. You can use Convert.ToBoolean() or Boolean.TryParse(). Another way is to declare uninitialized bool variable and use if or switch operators to fill it with value.
28th May 2020, 11:26 AM
Igor Kostrikin
Igor Kostrikin - avatar
0
please, show your attempt
28th May 2020, 10:59 AM
Igor Kostrikin
Igor Kostrikin - avatar
0
https://code.sololearn.com/c2Wt3Q967zG3/?ref=app sth like that If i cant use ReadLine to declare bool so what i should use?I want to do it in the easiest way if possible
28th May 2020, 11:06 AM
Matthew
Matthew - avatar