string s = "0723-1-邓淑洲、邓家龙"; int index1 = s.IndexOf('-'); if (index1 < 0) return; // not int int index2 = s.IndexOf('-', index1 + 1); if (index2 < 0) return // not int string ss = s.Substring(index1 + 1, index2 - index1 - 1); int result = 0; if (int.TryParse(ss, out result)) { // int } else { // not int }
int index1 = s.IndexOf('-'); if (index1 < 0) return; // not int
int index2 = s.IndexOf('-', index1 + 1);
if (index2 < 0) return // not int string ss = s.Substring(index1 + 1, index2 - index1 - 1);
int result = 0;
if (int.TryParse(ss, out result))
{
// int
}
else
{
// not int
}