我有这个示例数据
数据:P,B,B,T,P
所以它会像这样输出
但发生在我身上的是
我想要的是每条领带都不能增加到X轴。我怎么能得到它?
这是我到目前为止所尝试的内容:
string[] scoreboardWinner = new string[]
{
"P ","B ","T ",
"BP ","B P","B B","BB ",
"PB ","P B","P P","PP ",
"TP ","TB ","T P","T B",
"TTT",
"BBP","BPB","BPP","BBB",
"PPB","PBP","PBB","PPP"
};
private void XandYaxis() {
string[,] table = new string[104, 6];
string newPreviousValue = "placeholder";
int xIndex = -1;
int yIndex = 0;
if (gametable_no == 1)
{
for (int i = 0; i < list.Count; i++)
{
newString[0] += list[i].r;
}
string[] newChars = newString[0].Split(',');
if (table.GetLength(0) < xIndex)
{
break;
}
if (result.Equals(newPreviousValue) && yIndex < table.GetLength(1) - 1)
{
yIndex += 1;
table[xIndex, yIndex] = result;
}
else
{
xIndex += 1;
yIndex = 0;
table[xIndex, yIndex] = result;
}
}
}
我还尝试在
中添加if else语句if (result.Equals(newPreviousValue) && yIndex < table.GetLength(1) - 1)
{
string newResult = scoreboardWinner[2];
if (previousValue.Contains(newResult))
{
yIndex += 1;
table[xIndex, yIndex] = result;
}
}
}
但它不起作用。
顺便说一下scoreboardWinner[2]
=“T”;这是TIE
答案 0 :(得分:0)
保持在同一列上的非几何条件目前为result.Equals(newPreviousValue)
,其读取&#34;新结果与前一个相同。&#34;
您希望条件为&#34;新结果与之前相同,或结果为TIE。&#34;
修改条件以通过替换
来反映这一点 result.Equals(newPreviousValue)
带
(result.Equals(newPreviousValue) || result == "T ")
。