Find Longest String in String Array
Posted by robert on Oct 04, 2021 in CSharp, .net, programming
Problem
Given an dictionary with string values, find the longest string value in the dictionary.
Solution
using System.Linq;
public static class Helper
{
public static string FindLongestDictionaryEntry(Dictionary<object, string> existingDictionary)
{
return existingDictionary.Values.OrderByDescending(x => x).FirstOrDefault();
}
}
You must be logged in to see the comments. Log in now!