This question already has an answer here:
这个问题在这里已有答案:
- find if an integer exists in a list of integers 7 answers
查找整数列表中是否存在整数7个答案
i'm currently coding my own Sudoku in Windows Forms C# and I currently have Problems how to check if an integer is already in my list.
我目前正在Windows Forms C#中编写自己的数独编码,我目前有问题如何检查我的列表中是否已存在整数。
for (int i = 0; i < 9; i++)
{
List<int> list = new List<int>();
for(int j = 0; j < 9; j++)
{
list.Add(sodukuPlayfield.grid[i, j]);
}
}
So I add all the number in a row to a list. But after that I wanna check if there is only one number from 1 - 9. How can I solve this?
所以我将所有数字连续添加到列表中。但在那之后我想检查1 - 9中是否只有一个数字。我怎么能解决这个问题?
Thank you.
1 个解决方案
#1
0
I'm not quite sure where you want to put the list checking, but this is how you check if a list contains a specific number:
我不太确定您要将列表检查放在哪里,但这是检查列表是否包含特定数字的方法:
List.Contains(number you're searching for)
List.Contains(您正在搜索的号码)
Hope it helps!
希望能帮助到你!
#1
0
I'm not quite sure where you want to put the list checking, but this is how you check if a list contains a specific number:
我不太确定您要将列表检查放在哪里,但这是检查列表是否包含特定数字的方法:
List.Contains(number you're searching for)
List.Contains(您正在搜索的号码)
Hope it helps!
希望能帮助到你!