cs11dotnet7/vscode/Chapter08/Ch08Ex03NumbersAsWordsApp/Program.cs
2022-03-02 08:51:03 +00:00

16 lines
404 B
C#

using Packt.Shared; // ToWords extension method
using System.Numerics; // BigInteger
Write("Enter a number up to twenty one digits long: ");
string? input = ReadLine();
if (input is null) return;
if (input.Length > 21)
{
WriteLine("I cannot handle more than twenty one digits!");
return;
}
BigInteger number = BigInteger.Parse(input);
WriteLine($"{number:N0} in words is {number.ToWords()}.");