string sub = null;
int count = 0; //记录一共有多少个数字单元(一个连续的数字串作为一个单元)
foreach (char c in str)
{
if ( char.IsDigit(c) )
{
sub += c;
}
else if (sub != null)
{
count++;
sub = null;
}
}
sub = null;
int index = 0;
int[] Data = new int[count];
foreach (char c in str)
{
if ( char.IsDigit(c) )
{
sub += c;
}
else if (sub != null)
{
Data[index] = int.Parse(sub); // 取得数字
sub = null;
index++;
}
}