c# - How can I make my program stop reading user input when no input is given? -


i trying make program calculates specific data numbers given user. in example, program counts amount of numbers in range (10,103) divisible 2, , amount of numbers in range (15,50) divisible 3 within numbers given user. on stage, program gives results, when 10 numbers given (as specified in loop). how can make program stop reading numbers , give results when user imputs empty line no matter if he, entered 5 or 100 numbers before?

here code, looks now:

using system;  namespace program1 {     class mainclass     {         public static void main (string[] args)         {             int input10_103_div_2 = 0;             int input15_50_div_3 = 0;              (int = 0; < 10; i++)             {                 string input = console.readline ();                 double xinput = double.parse (input);                  if (xinput > 10 && xinput <= 103 && (xinput % 2) == 0)                 {                     input10_103_div_2++;                 }                 if (xinput > 15 && xinput < 50 && (xinput % 3) == 0)                  {                     input15_50_div_3++;                 }             }             console.writeline ("amount of numbers in range (10,103) divisible 2: " + input10_103_div_2);             console.writeline ("amount of numbers in range (15,50) divisible 3: " + input15_50_div_3);         }     } } 

if want restructure loop, can use do while loop:

string input; do{     input = console.readline();     //stuff } while(!string.isnullorempty(input)); 

if want able break early:

string input = console.readline (); if(string.isnullorempty(str))   break; double xinput = double.parse (input);    

Comments