It is necessary for the user to enter a number that will mean the number of characters after the comma of the number PI. I can't do it with the number 4 for some reason. Well, in general, not all numbers in the range from 0-14 work correctly.
static void Main(string[] args) { var numberPi = Math.PI.ToString(); Console.WriteLine("Digits affter dot:"); string userInput = Console.ReadLine(); string newtext4 = Regex.Replace(numberPi.ToString(), @"(\d{"+userInput+"})", string.Empty); Console.WriteLine("The Pi is:{0}",newtext4.ToString()); Console.ReadKey(); }
3.
then you can simply take a fixed string of the requested length +2 - Mike