我有一个下面提到的字符串,我正在从该字符串中提取一个2D数组(我正在成功执行此操作),问题是我不知道如何退出while循环。
00000000,00000000,10100111,10100101,11111101,11111111,00000111,00000000,
00000000,00000000,11100010,00100010,11111111,11111111,00000000,10000000,
00000000,00000000,00001001,00001000,00111111,00111111,00000000,00000000,
00100000,00100000,10101110,10100010,10111110,10111110,00000000,00001000,
00000000,00111000,00100011,01111110,01111111,01000011,01000000,01111000,
00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,
00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,
我试图将“ x”放在字符串的末尾,并像这样运行while循环,它可以工作,但是对我来说不可行,因为我必须从数百个文件中读取该字符串。
while (Data_string[counter] != 'x' )
{
while (Data_string[counter] != ',')
{
if (Data_string[counter] != '\n')
SubString += Data_string[counter];
counter++;
}
// here I use Substring to covert to int and then set Substring to empty string
}
所以我正在寻找一种有效的解决方案,所以我不必更改字符串,
谢谢..
只需使用
while (counter < Data_string.Length)
{
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句