-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