cs11dotnet7/vscode/Chapter08/Ch08Ex03NumbersAsWordsApp/Program.cs

16 lines
404 B
C#
Raw Normal View History

2022-03-02 09:51:03 +01:00
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()}.");