Reputation: 51
I'm need generate a random number an insert a space or comma between digits. This value will be speaked using AWS Polly. Without space, to 6565, she sepeak "six thousand five hundred and sixty five". Part of the code, generating the random number, I already got it, but I don't know how to insert the space between the digits.
Anyone can help me? See bellow:
var withoutSpaces = new Random().Next(10000,100000);
var withSpaces = ????????
return withSpaces;
Wait your answer!
Upvotes: 1
Views: 534
Reputation: 532
var withoutSpaces = new Random().Next(10000, 100000);
string withSpaces = "";
for (int i = 0; i < withoutSpaces.ToString().Length; i++)
{
string test = withoutSpaces.ToString().ElementAt(i) + " ";
withSpaces += test;
}
string WithSpacesFinal = withSpaces.Trim();
This should do it for you
Upvotes: 2