Reputation: 47
I am familiar with generating random numbers, but this would be more like a code I guess. What I want it to do is follow a specified pattern and generate numbers for every x in the code while there are some set numbers. The code pattern would be something like this: xx0xxxx00xx0. I want the program to make the x's into something random, but keep the zero's. If you have any questions or any way I could make my question better, feel free to comment! Also if this is a duplicate question, just tell me and I can remove it. Thanks!
Upvotes: 0
Views: 420
Reputation: 108
You could try using regex. A simple example to get you started would be:
static void Main()
{
var code = "xx0xxxx00xx0";
var numStr = Regex.Replace(code, @"([^0-9.])", x => new Random().Next(1,9).ToString());
Console.WriteLine(numStr);
}
// 450871700340
With this approach, you could really give it any sort of code with that x0 format you are using.
Upvotes: 4