hi people,

I'm supposed to be creating something like a dynamic item number generator.

for example:

FROM: A 1 0 111
TO: B 2 0 112

should produce:
A 1 0 111
A 1 0 112
B 1 0 111
B 1 0 112

this would be quite easy using 4 for loops but the problem is the user should be able to control the length of the input. they can specify how long they want the numbers to be:

length [5]
FROM: A 1 0 1 111
TO: B 1 0 1 112


length [7]
FROM: A 1 0 1 111 A 1
TO: B 1 0 1 111 B 2

you get the picture. I'm really stumped and do not know what to do. any help would be really appreciated. thanks!

9 Years
Discussion Span
Last Post by gp04lch

So, you need to split the string into chunks and work by value, and then go from 'start' to 'end' for each one.


yes i thought of that concept too. but how do i go about defining how many loops i need? its dynamic and therefore not fixed.

i'd really appreciate it if you can provide me with an example.

thanks in advance.


Array size can be specified dynamically like

int[] AnArray;
      int iSize = 10;

      AnArray = new int [iSize];

So user can control the length


thanks for the reply. but i'm actually not talking about that problem. what i meant was:

1. how do i make my loops depth follow the width of the array?
2. (new question) how do i differentiate between numbers and characters and place them in the loops?


heres some psudo code
split string get bunch of chunks
define output area

proc dostuff(chunks)
take first chunk
for all the bits of last chunk
for all the output areas
make a copy of current output area + bit
dostuff(chunks - current chunk)


i almost got it. but i cant seem to do the copy part.
here's my code:

public void GenerateCode(string[,] segmentList)
 for (int i = intfrom; i <= intto; i++)
     GenerateCode(newsegment minus one row of segmentlist);
     //here's the problem, how do i get 'i' to be passed into the method above?
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.