c# - How to generate a list of lists of digits? -


i want generate list of lists 1 below. how in c#?

list<list<int>> data = {{0,0,0,0}, {0,0,0,1}, {0,0,0,2}, ..., {9,9,9,9}}; 

another option...

var data = enumerable.range(0, 10000)                      .select(x => new list<int>                          { x / 1000, (x / 100) % 10, (x / 10) % 10, x % 10 })                      .tolist(); 

and if want generate arbitrary number of digits can this:

int n = 4;  // number of digits  var data = enumerable.range(0, (int)math.pow(10, n))                      .select(x =>                          enumerable.range(1, n)                                    .select(y =>                                        (x / (int)math.pow(10, n - y)) % 10)                                    .tolist())                      .tolist(); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -