-1
我是C#的初学者,我有一个任务来创建一个程序来排序两个数组,并根据用户颜色输入查找最大的鱼。我不知道如何使它工作。任何人都可以给我一些指点吗?这是我到目前为止。在数组中搜索并找到最大的对象
Console.WriteLine("Select a fish color. \nEnter only the number.\n1.
Black\n2. Green\n3. Red\n4. Blue\n5. Yellow\nEnter Your Selection:");
string userColor = Console.ReadLine();
int value;
while (!(int.TryParse(userColor, out value) && value >=1 && value <=5))
{
Console.WriteLine("Please type only numbers from 1 to 5");
userColor = Console.ReadLine();
}
int color = int.Parse(userColor);
string[] colors = new string[] { "Black", "Black", "Green", "Red", "Blue", "Yellow", "Black", "Green", "Red", "Blue", "Yellow", "Black", "Green", "Red", "Blue","Yellow"};
double[] lenght = new double[] { 8.5, 9.8, 10.9, 40, 36, 45, 43, 12, 17.8, 13.5, 14.9, 27.7, 26.9, 50, 60,13 };
Console.WriteLine("You chose " + colors[color]);
Console.WriteLine("The biggest " + colors[color] + " fish is " + lenght[color]+ " inches long.");
解决方案很简单。我希望你痒痒你的脑细胞,以便你成为美妙的堆栈溢出社区的一部分。 ZIP是Linq阅读的方式之一 – Ramankingdom
https://msdn.microsoft.com/zh-cn/library/dd267698(v=vs.110).aspx – Ramankingdom