public static int[] ReturnIndexes()
{
// Default values should be -1
int index1 = -1;
int index2 = -1;
int index3 = -1;
int index4 = -1;
int index5 = -1;
int index6 = -1;
int index7 = -1;
int index8 = -1;
int index9 = -1;
string param = "#1#1#2";
//Sample param values
//#1#1#1#2#3#4
//#1
//#2#1
//#3#3#1
string[] index = param.Split('#').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
switch (index.Length)
{
case 1:
index1 = Convert.ToInt32(index[0]) - 1;
break;
case 2:
index1 = Convert.ToInt32(index[0]) - 1;
index2 = Convert.ToInt32(index[1]) - 1;
break;
case 3:
index1 = Convert.ToInt32(index[0]) - 1;
index2 = Convert.ToInt32(index[1]) - 1;
index3 = Convert.ToInt32(index[2]) - 1;
break;
case 4:
index1 = Convert.ToInt32(index[0]) - 1;
index2 = Convert.ToInt32(index[1]) - 1;
index3 = Convert.ToInt32(index[2]) - 1;
index4 = Convert.ToInt32(index[3]) - 1;
break;
case 5:
index1 = Convert.ToInt32(index[0]) - 1;
index2 = Convert.ToInt32(index[1]) - 1;
index3 = Convert.ToInt32(index[2]) - 1;
index4 = Convert.ToInt32(index[3]) - 1;
index5 = Convert.ToInt32(index[4]) - 1;
break;
case 6:
index1 = Convert.ToInt32(index[0]) - 1;
index2 = Convert.ToInt32(index[1]) - 1;
index3 = Convert.ToInt32(index[2]) - 1;
index4 = Convert.ToInt32(index[3]) - 1;
index5 = Convert.ToInt32(index[4]) - 1;
index6 = Convert.ToInt32(index[5]) - 1;
break;
case 7:
index1 = Convert.ToInt32(index[0]) - 1;
index2 = Convert.ToInt32(index[1]) - 1;
index3 = Convert.ToInt32(index[2]) - 1;
index4 = Convert.ToInt32(index[3]) - 1;
index5 = Convert.ToInt32(index[4]) - 1;
index6 = Convert.ToInt32(index[5]) - 1;
index7 = Convert.ToInt32(index[6]) - 1;
break;
case 8:
index1 = Convert.ToInt32(index[0]) - 1;
index2 = Convert.ToInt32(index[1]) - 1;
index3 = Convert.ToInt32(index[2]) - 1;
index4 = Convert.ToInt32(index[3]) - 1;
index5 = Convert.ToInt32(index[4]) - 1;
index6 = Convert.ToInt32(index[5]) - 1;
index7 = Convert.ToInt32(index[6]) - 1;
index8 = Convert.ToInt32(index[7]) - 1;
break;
case 9:
index1 = Convert.ToInt32(index[0]) - 1;
index2 = Convert.ToInt32(index[1]) - 1;
index3 = Convert.ToInt32(index[2]) - 1;
index4 = Convert.ToInt32(index[3]) - 1;
index5 = Convert.ToInt32(index[4]) - 1;
index6 = Convert.ToInt32(index[5]) - 1;
index7 = Convert.ToInt32(index[6]) - 1;
index8 = Convert.ToInt32(index[7]) - 1;
index9 = Convert.ToInt32(index[8]) - 1;
break;
}
return new int[]{ index1, index2, index3, index4, index5, index6, index7, index8, index9 };
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE