vendredi 25 septembre 2015

If and Else if block only runs the Else if

It would seem like this whole simple code is correct, but when I click start and type in any number such as 4 or 6, the only output is the "else if" every time!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int c = Convert.ToInt32(Console.Read());
            if (c >= 0  && c < 5)
            {
                Console.Write("# is > 0");
            } 
            else if (c >= 5)
            {
                Console.Write("# is > 5");
            }
            Console.ReadKey();

        }
    }
}

Aucun commentaire:

Enregistrer un commentaire