forum

Home / DeveloperSection / Forums / Write another function for this code using C#

Write another function for this code using C#

E E Cummings221705-Oct-2013
using System; 
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string numberIn;
            int numberOut;

            numberIn = Console.ReadLine();

            while (!int.TryParse(numberIn, out numberOut) || numberOut < 0)
            {
                Console.WriteLine("Invalid. Enter a number that's 0 or higher.");
                numberIn = Console.ReadLine();
            }
        }
    }
}

Updated on 05-Oct-2013

Can you answer this question?


Answer

1 Answers

Liked By