string data = "0000062456"
how to split this string on 5 pieces so that I have:
part[0] = "00";
part[1] = "00";
part[2] = "06";
part[3] = "24";
part[4] = "56";
part[0] = myString.Substring(0,2);
part[1] = myString.Substring(2,2);
part[2] = myString.Substring(4,2);
part[3] = myString.Substring(6,2);
part[4] = myString.Substring(8,2);
This can of course be easily converted to a function, using the index you need the substring from:
string getFromIndex(int arrIndex, int length)
{
return myString.Substring(arrIndex * 2, length);
}
If you really want to get fancy, you can create an extension method as well.
public static string getFromIndex(this string str, int arrIndex, int length)
{
return str.Substring(arrIndex * 2, length);
}