我有一个下面提到的字符串我正在从这个字符串中提取一个二维数组(我正在成功地做)问题是我不知道如何退出 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)
{
}
关于c# - 如何在c#中的String末尾跳出while循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56323238/