C# How to put variable into bool | Sololearn: Learn to code for FREE!

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

5/28/2020 10:39:12 AM

Matthew

3 Answers

New Answer

+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.

0

please, show your attempt

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