(Tried to look for earlier answers for my question and didn't find any...)
lets say I have an array like this :
string[] chars = {"1", "x", "1", "x", "x", "x", "x", "x", "1", "1", "1", "x", "1", "x", "x", "x"};
I need to find the way to extract the max number of "x" in a row in an array,
so in this example I have total of 10 "x" but only 5 in a row,
so I need the extract the number 5.
Tried this method... but how of course it wont work with the first char (i-1).
string[] chars = { "1", "x", "1", "x", "x", "x", "x", "x", "1", "1", "1", "x", "1", "x", "x", "x" };
int count = 0;
for (int i=0; i < chars.Length; i++)
{
if ((chars[i] == "x") && (chars[i] == chars[i - 1])) ;
count++;
}
Console.WriteLine(count);
Thanks for the help !
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…