How to return true or false (bool) from method in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 13;

            if (Odd(n))
                Console.WriteLine("odd");
            else
                Console.WriteLine("even");
        }

        public static bool Odd(int n)
        {
            return n % 2 == 1;
        }
    }
}


/*
run:

odd

*/

 



answered Jan 3, 2017 by avibootz

Related questions

1 answer 253 views
1 answer 241 views
1 answer 229 views
2 answers 357 views
357 views asked May 18, 2015 by avibootz
1 answer 214 views
1 answer 180 views
...