I am trying to find the shortest and longest string value based on length and im getting stuck. As of now the script exits after the writeline. I think the code needs some h
As @DStanley and @RenniePet pointed out, your original code doesn't exactly do what you're trying to accomplish. I do believe you wanted to cycle through the member of your string array and fill them with console inputs. A working code would look like this:
string[] word = new string[5];
for (int i = 0; i < word.Length; i++)
{
Console.Write("Input text: ");
word[i] = Console.ReadLine();
}
List _sortedWords = word.ToList();
_sortedWords.Sort((x, y) => x.Length.CompareTo(y.Length));
Console.WriteLine("Smaller: " + _sortedWords[0]);
Console.WriteLine("Larget: " + _sortedWords[_sortedWords.Count-1]);
Console.ReadLine();