Quantcast
Channel: Compare strings for equality - Stack Overflow
Browsing latest articles
Browse All 5 View Live

Answer by Jonathan Wood for Compare strings for equality

Here's a version that uses less LINQ than some of the other answers and might possibly be more performant.string GetEqualName(IEnumerable<string> strList){ StringBuilder builder = new...

View Article



Answer by Tim Schmelter for Compare strings for equality

Here's a different method which does what you want. I looks for the longest common substring from left to right using a HashSet<string>:string GetCommonStartsWith(IEnumerable<string>...

View Article

Answer by anaximander for Compare strings for equality

This little function does basically the same as your version, but shorter.string GetEqualName(IEnumerable<string> strList){ int limit = strList.Min(s => s.Length); int i = 0; for (; i <...

View Article

Answer by Servy for Compare strings for equality

You can Zip two strings together, take the pairs that are equal, and then create a string of those characters.public static string LargestCommonPrefix(string first, string second){ return new...

View Article

Compare strings for equality

I want to compare a collection of strings and return the the equal parts until a not equal part occurs. (and remove traling whitespace).example:List<string> strList = new...

View Article

Browsing latest articles
Browse All 5 View Live




Latest Images