Reputation: 3431
I need obtains some character from the names of a images, the format of that names is:
141000000005.jpg
, 141000150005.jpg
, 141004600007.jpg
...etc. I make the split()
to separe the ".jpg"
, now I need obtains the character from the position 3 to 10, for example:
141000000005 --> 00000000
141000150005 --> 00015000
141004600007 --> 00460000
The names images comes in a List<string>
, so I in this moment I make this:
char[] timeCodeArray = timeCodeList[i].ToCharArray();
string timeCodeArrayString = Convert.ToString(timeCodeArray[3].ToString() +
timeCodeArray[4].ToString() + timeCodeArray[5].ToString() + timeCodeArray[6].ToString() +
timeCodeArray[7].ToString() + timeCodeArray[8].ToString() + timeCodeArray[9].ToString() +
timeCodeArray[10].ToString());
How can I make this with substring??
Upvotes: 0
Views: 334
Reputation: 39530
Looks like you want myString.Substring(3,8)
Just for reference, though it's a lousy solution for this particular problem, if you concatenate lots of strings with '+', you get a string, so you don't need to call Convert.ToString on the result.
Upvotes: 0
Reputation: 1414
mystring.Substring(3,7) -> return a string which starts at character 3 and take 7 charcaters
Upvotes: 1