我试图根据长度找到最短和最长的字符串值,但我被卡住了。到目前为止,脚本在写入行之后退出。我认为代码需要一些帮助,我认为 for 循环不能单独工作。任何援助将不胜感激。
for (int i = 5; i <0; i++)
{
string[] word = new string[5];
Console.WriteLine("Type in a word");
word[i] = Console.ReadLine();
int length = word[i].Length;
int min = word[0].Length;
int max = word[0].Length;
string maxx;
string minn;
if (length > max)
{
maxx = word[i];
Console.Write("Shortest");
}
if (length < min)
{
minn = word[i];
Console.Write("Longest");
}
}
Console.ReadKey(true);
}