111,129
社区成员
发帖
与我相关
我的任务
分享string s = "10003-45000";
string[] fields = s.Split("-".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
int a, b;
if (!int.TryParse(fields[0], out a) || !int.TryParse(fields[1], out b)) return;
Console.WriteLine(a);
Console.WriteLine(b);
void Main()
{
string ss = "10003-45000 ";
foreach (Match m in Regex.Matches(ss, @"\d*"))
{
Console.WriteLine(m.Value);
}
}
//10003
//45000
void Main()
{
string ss = "10003-45000 ";
foreach (Match m in Regex.Matches(ss, @"\d*"))
{
Console.WriteLine(m.Value);
}
}
//10003
//45000
void Main()
{
string ss = "10003-45000 ";
int m =int.Parse( ss.Substring(0, ss.IndexOf("-")));
int n = int.Parse(ss.Replace(m + "-",""));
Console.WriteLine( m+" "+n);
}
//10003 45000
void Main()
{
string ss = "10003-45000 ";
int m =int.Parse( ss.Substring(0, ss.IndexOf("-")));
int n = int.Parse(ss.Replace(m + "-",""));
Console.WriteLine( m+" "+n);
}
//10003 45000
void Main()
{
string ss = "10003-45000 ";
int m =int.Parse( ss.Substring(0, ss.IndexOf("-")));
int n = int.Parse(ss.Replace(m + "-",""));
Console.WriteLine( m+" "+n);
}
//10003 45000