I have pseudo-code but think it needs some optimization.

The pseudo-code I think one could use is something like this

Dim resultNeeded = 123 Dim x = 0 Dim y = 0 For x as int16 = 0 to 1000 For y as int16 = 0 to 1000 Perform some quick calculation in here to get resultNeeded Next Next

What is inside the loop does not matter. What I am wanting to know is to see if the above loop is the best way to iterate through the two combinations of 1000 or is there a quicker way in VB.Net or C#. Thanks!

Basically set up two variables x, y such that each number is iterated through a loop all the way up to 1000 for both x and y running an algorithm on the result to see if it matches a certain criteria.

I am trying to run an algorithm that when using two numbers between 0-1000 will give a certain output - lets say a key like ACD123-45232.

All I am wanting to know is how to iterate through the two sets of 0-1000 the fastest way and run the algorithm through each iteration to test if it matches the value like above. The algorithm doesn't matter and I know in VB.Net you can use a For Each/Next scenario taking each number and looping it against the other number but I feel there has to be a better way. Any advice is appreciated. Thanks! - Remember any actual code is VB.Net or C#. Thanks!