我试图让用户输入 10 个数字并将它们存储到数组中。然后提示用户输入任何数字以检查该数字是否已存储在数组中。当我输入任何数字时,屏幕将消失,我无法验证该数字是否已存在。请看我的代码。提前致谢。
static void Main(string[] args)
{
int[] numCheck = new int[10];
int[] userInput = new int[1];
Console.WriteLine("Please enter 10 numbers: ");
for (int i = 0; i < 10; i++)
{
Console.Write("Number {0}: ", i + 1);
numCheck[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine("Please enter any number to check if the number already exist");
for (int j = 0; j <= 10; j++)
{
if (userInput == numCheck)
{
Console.Write("The number {0} is in the index", numCheck);
userInput[j] = int.Parse(Console.ReadLine());
}
else
{
Console.Write("The number {} is not in the index", numCheck);
}
}