c#从字符串中取出所有的指定字符串存入数组变量 比如:string a = "abcdefgabcdefgabcdefg";我想取出所有的fg字串并存入数组变量中。应该怎么做呢?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string a = "abcdefgabcdefgabcdefg"; string item = "fg"; int startindex = 0; int index = a.IndexOf(item, startindex); List<string> items = new List<string>(); while(index > -1) { startindex = index + 1; items.Add(item); if(startindex < a.Length) { index = a.IndexOf(item, startindex); } } 感谢zhujiazhi,唉,脑子转不过来了。结帖了。 C#winForm打印条码 同一个项目,同样的代码,不同平台,GetHashCode问题 【求助】:ComboBox+TextBox 与“类”的关联问题 DataSet排序 安装打印机驱动的一些问题 关于XSL嵌套循环中条件判断的问题 dataGridView保存修改的问题 高手请进:RichTextBox的问题 求助,正则表达式问题,高手帮帮忙啊,在线等 查询 及其 显示问题!!!! C#winform 问题 wpf中MenuItem的问题!!!急!!
string item = "fg";
int startindex = 0;
int index = a.IndexOf(item, startindex);
List<string> items = new List<string>();
while(index > -1)
{
startindex = index + 1;
items.Add(item);
if(startindex < a.Length)
{
index = a.IndexOf(item, startindex);
}
}