- Home /
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
But what is happening to me is this
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 .
capture4.png
(1.7 kB)
capture3.png
(2.0 kB)
Comment
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Increment position every different value (C# UNITY) 1 Answer
Multiple Cars not working 1 Answer
Array not updating in inspector 0 Answers