[Solved] C# How to find how much of numbers are Entered? [closed]


To get the number entered as a double, you would use double.TryParse Google here to convert “x” into “t” and then act on it somehow. If you want something more specific, you need to share what you’re trying to do (expected input/expected output). Your English “how much of numbers are Entered” is not clear.

  static void Main(string[] args)
{
    string x;               
    double t,tot=0, s = 1;
    while ((x = Console.ReadLine()) != null)
    {        
        if(double.TryParse(x,out t))
        {
            //t is now the number entered as a double -- process
            tot+= t;
            Console.WriteLine(s==1?"Please enter your second number":"The sum of your "+s.ToString()+" numbers is "+tot.ToString("N0"));
            s++;


        }else{

            Console.WriteLine("You may only enter numbers. Please try again.\n");

        }

    }

2

solved C# How to find how much of numbers are Entered? [closed]