Why does the “System.ArgumentOutOfRangeException” error occur?

enter image description here

Closed due to the fact that off-topic participants Vadim Ovchinnikov , αλεχολυτ , ermak0ff , kmv , BadCatss Mar 13 '17 at 17:31 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Vadim Ovchinnikov, αλεχολυτ, ermak0ff, kmv, BadCatss
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • You probably want to use Console.ReadLine() - Ev_Hyper instead of Console.Read()
  • up to fifty one digits? - BadCatss
  • @BadCats value k in the picture 51 - Igor
  • But if I can't use Round for rounding - what should I do then? I mean by the condition - k can be more than 15, which is not suitable for Round - BadCatss
  • 2
    @BadCats on what condition? It may be worth explaining what you want to achieve? Double rounding to more than 15 digits does not make sense. For Decimal - 28: msdn.microsoft.com/en-us/library/zy06z30k(v=vs.110).aspx - Igor

2 answers 2

rounding up to fifty one digits? ( k value in the picture 51 )

https://msdn.microsoft.com/en-us/library/75ks3aby(v=vs.110).aspx -

ArgumentOutOfRangeException - digits is less than 0 or greater than 15.

(number of digits less than 0 or greater than 15)

    In the Math.Round method, the second number means the number of digits (digits after the decimal point) to which the number should be rounded. This method can have only one to fifteen. As I see, the answer is entered through the console, so you need to use catch {} and try {} to prevent the user from entering unwanted digits.