Bue*_*ena 1 c# string parsing integer winforms
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
Run Code Online (Sandbox Code Playgroud)
我怎么能这样说呢?
使用字符串类的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
Run Code Online (Sandbox Code Playgroud)