Answers for "c# find the smallest string in an array of strings"

C#
0

c# find the smallest string in an array of strings

string[] names = new string[3]{
     "Tom", "and", "jerry"
};

string minValue = names[0];
foreach (string name in names)
{
     if (name.Length < minValue.Length)
     {
          minValue = name;
     }
}

Console.WriteLine(minValue);
Posted by: Guest on May-07-2021

Code answers related to "c# find the smallest string in an array of strings"

C# Answers by Framework

Browse Popular Code Answers by Language