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
try this
static void Main(string[] args)
{
string[] array1 = { "Cats and ratsasdfasdf", "just rats and the just catest", "rats" };
var shortString = array1[0];
var longString = array1[0];
/*Code for Find Shortest and longest string in Array*/
foreach (var t in array1)
{
if (shortString.Length > t.Length)
shortString = t;
if (longString.Length < t.Length)
longString = t;
}
Console.WriteLine("shortest string is:" + shortString);
Console.WriteLine("Longest string is:" + longString);
Console.Read();
}