Tuesday, February 2, 2016

How to get the previous value from string array c#(Unity)



I have this example data



Data: P ,B ,B ,T ,P



This must be something like this


enter image description here


But what is happening to me is this


enter image description here


here's my code


string[,] table = new string[104, 6];

string newPreviousValue = "placeholder";
int xIndex = -1;
int yIndex = 0;
if (result.Equals(newPreviousValue) && yIndex < table.GetLength(1) - 1)
{
yIndex += 1;
table[xIndex, yIndex] = result;
}

else

{
xIndex += 1;
yIndex = 0;
table[xIndex, yIndex] = result;
}

So you won't get confuse the result variable is the data generator. What could be missing on my condition?


I tried doing something like this


if (result.Equals(newPreviousValue) && result.Equals(newPreviousValueTie) && yIndex < table.GetLength(1) - 1) but what's happening here is they're all in y axis falling in line .




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...