Need help with accepting decimals as input in C#

后端 未结 3 1199
鱼传尺愫
鱼传尺愫 2021-01-20 16:30

I have written a program in C# that runs the Pythagorean Theorem. I would love some help on allowing the program to accept decimal points from the user input. This is what I

3条回答
  •  不知归路
    2021-01-20 17:14

    static decimal RequestDecimal(string message)
    {
        decimal result;
        do 
        {
             Console.WriteLine(message);
        }
        while (!decimal.TryParse(Console.ReadLine(), out result));
        return result;
    }
    

提交回复
热议问题