日期:2014-05-17 浏览次数:20794 次
string str = "a,g,df,ww,r,ehg,er,gh,wrg,wre,fgs,df,wgbh,tjh,r,h,rew,hte,h,saf";
int index = 5;
string[] array = str.Split(',');
string[] temp = new string[index];
Array.Copy(array, 0, temp, 0, index);
Console.WriteLine(string.Join(",", temp));
string str = "a,g,df,ww,r,ehg,er,gh,wrg,wre,fgs,df,wgbh,tjh,r,h,rew,hte,h,saf";
int sep = 5;
int index = -1, count = 0;
while (count != sep)
{
index = str.IndexOf(',', index + 1);
if (index != -1)
count++;
}
Console.WriteLine(str.Substring(0, index));