Jeff Verdegan wrote:Create a counter before you enter your loop. Increment it each pass through the loop. Use that as the index into the other array.
Or, if you're using Lists rather than arrays, just iterate both Lists at the same time.
However, if you're using a "parallel array" (or "parallel list") approach, that's usually a sign of a design error. A better approach would probably be to define a class that contains one "row" across corresponding elements of all of your arrays.
Jeff Verdegan wrote:
Joshua Jones wrote:now I would like to make some sort of selection to "update" the value of TypeVal with the implied values based on whether ProjectType is either Consultancy or development so I can make calculations with that value.
And the initial code you posted does just that. (Aside from the syntax error of not covering the situation where it's neither "Consutancy" no "Development".)
So what specific problem are you having?
Jeff Verdegan wrote:
Joshua Jones wrote:
Assume the Conditions are true in both cases. the Project Type will always be either Consultancy or Development. I just want to get the value of Typeval out of the if statement so I can use it in calculations
You and I can make that assumption, but the compiler can't know that this will be the case. You have to cover every possible case.
The usual way would be something like this:
Paul Clapham wrote:
Mohana Rao Sv wrote:Is your if condition true in either of the cases.
Exactly. And what value do you want TypeVal to have if it isn't?