Hi
Member 12277263
,
Your problem is basically to understand if
currentVer[0]
is a string ('vername') or not, and according to that parse the rest of the version information.
A quick workaround is:
1) Check if the first index is a string ('vername').
2) According to that set the parsing index starter - if it should start from 0, or 1.
public void VerInfo(string verString)
{
string[] currentVer;
if (verString.Contains("."))
currentVer = verString.Split(".".ToCharArray());
else
currentVer = verString.Split(":".ToCharArray());
int Index = 0;
if (currentVer[0].ToLower().Equals("vername"))
Index = 1;
else Index;
byte a = Convert.ToByte(currentVer[Index++]);
byte b = Convert.ToByte(currentVer[Index++]);
byte c = Convert.ToByte(currentVer[Index]);
}
You can further refine the IF-ELSE statement by replacing with ternary operator. I didn't do that for sake of clarity.