1
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
我怎么能这样说呢?如何解析字符串的特定字符为整数?
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
我怎么能这样说呢?如何解析字符串的特定字符为整数?
使用字符串类的子串方法来提取所需的一组字符。
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
没有int.Parse
将范围,所以无论是:
Substring
第一,然后在子使用int.Parse
so:
x = int.Parse(abc.Substring(0,2));
etc
好的。解决了,谢谢! – Buena
不客气。 – Adil