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 243 views
1 answer 233 views
1 answer 220 views
2 answers 350 views
350 views asked May 18, 2015 by avibootz
1 answer 206 views
1 answer 172 views
...