I have a List<string>
, which contains payrollnumbers as strings, e.g.:
List<string> payrollnumbers = new List<string>() { "0","1","3" };
I want to get the next value in the list, so:
- if
currpayrollnumber
is 0, I want to get the value 1, - if
currpayrollnumber
is 1, I want to get the value 3, - etc.
I have the following code, however it does not work like expected:
List<string> payrollnumbers = new List<string>();
// fill payrollnumbers ...
var currpayrollIndex = payrollnumbers.IndexOf(currpayrollnumber);
var nextPayrollIndex = currpayrollIndex++;
var payrollnumber = payrollnumbers[nextPayrollIndex];