Link to home
Start Free TrialLog in
Avatar of jimbob_sf
jimbob_sfFlag for United States of America

asked on

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.
Avatar of ICaldwell
ICaldwell
Flag of United States of America image

This seems similar to what your trying to do:

http://www.codeproject.com/KB/recipes/diffengine.aspx
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.
ASKER CERTIFIED SOLUTION
Avatar of roeib
roeib

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of roeib
roeib

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