How to flip boolean variable from true to false in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b;

            b = true;

            Console.WriteLine(b);

            b = !b;
            Console.WriteLine(b);

            b = !b;
            Console.WriteLine(b);
        }
    }
}


/*
run:
    
True
False
True
   
*/

 



answered Dec 2, 2016 by avibootz

Related questions

1 answer 290 views
1 answer 262 views
2 answers 291 views
1 answer 257 views
1 answer 233 views
1 answer 323 views
1 answer 281 views
...