Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,950 questions

51,892 answers

573 users

How to use bool (boolean) in C#

3 Answers

0 votes
using System;

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

            if (b)
            {
                Console.WriteLine("true");
            }

            b = !b; 
            if (!b)
            {
                Console.WriteLine("false");
            }
        }
    }
}


/*
run:

true
false

*/

 



answered Jan 2, 2017 by avibootz
0 votes
using System;

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

            Console.WriteLine(b);

            b = !b;

            Console.WriteLine(b);
        }
    }
}


/*
run:

true
false

*/

 



answered Jan 2, 2017 by avibootz
0 votes
using System;

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

            int n = b ? 1 : 0;

            Console.WriteLine(n); 

        }
    }
}


/*
run:

1

*/

 



answered Jan 2, 2017 by avibootz

Related questions

2 answers 214 views
214 views asked Aug 30, 2016 by avibootz
1 answer 128 views
1 answer 153 views
153 views asked Feb 5, 2021 by avibootz
2 answers 292 views
292 views asked Feb 4, 2021 by avibootz
1 answer 182 views
1 answer 157 views
157 views asked Jan 17, 2017 by avibootz
1 answer 219 views
...