Boolean data type is declared with the keyword, bool. it would allow you to define either true or false. |
using System; //csc check_bool_1.cs //my example class check_bool { public string str; } class test { public static void Main() { //create object check_bool cb= new check_bool(); //out put inside a command window Console.WriteLine("Welcome to Hello world"); Console.Write("What is your name?: "); //read input from the commandline cb.str = Console.ReadLine(); Console.WriteLine("Hello: " + cb.str); bool admin ; if (cb.str=="manas") { admin= true; Console.WriteLine( cb.str + " He is an admin: = " + admin);} else { admin= false; Console.WriteLine( cb.str + " He is not an admin: = " + admin);} } } |