• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1194
  • Last Modified:

text compare in C#

Our application is written in C# .Net version 3.5. Part of our application is dedicated to displaying the user difference between 2 strings. Currently using the existing string functions of C#, we have the ability to let the user know the 2 strings are different. But, we want to let the user know more detail about the actual difference.

We would like the ability to color code the differences just like a file comparison tool does. In addition, it should highlight individual text differences and not just the full line. We have done some research to find a few tools out there that do this, but nothing that can be fully integrated within our C# application. By complete integration I mean, the ability to do the compare and show the color highlighted results in a 2 text boxes, side by side.

Any suggestions of existing tools that can be incorporated within C# will be appreciated.
1 Solution
This seems similar to what your trying to do:

If you want to do it on just one line, I think you would have to go character by character to see if there is a difference....
Here is the code -

string temp1 = "string";
string temp2 = "stringRemain";
string result = temp2.Replace(temp1,"");

Highlight "result " part and "String.concat" with original one.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

you can use the following Library :


its a porting of the Google Diff Library to C#, you can use it to mark any diff and on your Client Side add the remarkings.

hope this helps
In our company we use Beyond Compare" product from http://www.scootersoftware.com/. It's not free however ($30 per one copy) ...

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now