c# - Compare two strings and get the difference -
How can I compare two strings in C # and how to find the difference?
For example:
String 1: I have a car
string 2: I have a new car BMW
The result: New, BMW
You must make sure that except the big set
Is in the left hand (not sure that the pure Linq path is to get it):
Fixed zero main (string [] ARG) {string s1 = "I have a car A Car"; String s2 = "I have a new car BMW"; & Lt; String & gt; Diff; IEnumerable & LT; String & gt; Set 1 = s1.Split (''). Undoubtedly (); IEnumerable & LT; String & gt; Set2 = s2.Split (''). Undoubtedly (); If (set2count ()> set1count ()) {diff = set2.Except (set1) .toList (); } Else {diff = set1.Except (set2) .toList (); }}
Comments
Post a Comment