string abc = "07:00 - 19:00"
x = int.Parse(only first two characters) // should be 7
y = int.Parse(only 9th and 10th characters) // should be 19
请问我怎么说呢?
最佳答案
使用字符串类的Substring方法提取所需的字符集。
string abc = "07:00 - 19:00";
x = int.Parse(abc.Substring(0,2)); // should be 7
y = int.Parse(abc.Substring(8,2)); // should be 19
关于c# - 如何将字符串的特定字符解析为整数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11202236/