Q:

Write a C# Sharp program to reverse a boolean value

0

Write a C# Sharp program to reverse a boolean value

Sample Output:

Original value: False
Reverse value: True
Original value: True
Reverse value: False

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
namespace exercises
{
    class Program
    {
        static void Main(string[] args)
        {
           bool cat = false;
           bool dog = true;
           Console.WriteLine("Original value: "+cat);
           Console.WriteLine("Reverse value: "+test(cat));
           Console.WriteLine("Original value: "+dog);
           Console.WriteLine("Reverse value: " + test(dog));
        }
        public static bool test(bool boolean)
        {
            return !boolean;
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now