Is there anything available for .NET to get the differences on two lines?

I'm looking for a way to spot the differences between two lines and highlight them on both lines.

I suspect most of the "diff" libraries will not work as they show line differences (I believe).

Either an algorithm or a library will work.

Thanks Mark

+2


a source to share


4 answers


DiffPlex can handle many different "line" differences, including differences between characters and words. I think he can do whatever you ask for here.



+6


a source


From your question, you seem to have given up on using an existing program and decided to write your own because you think existing programs cannot show line differences.

However, WinMerge can display inline differences.



RioPc.png

Does this suit your needs? Or do you need to be a .NET component for some reason?

+2


a source


You probably want to explore the Levenshtein distance or . For a C # implementation of Levenshtein's algorithm see here (if you're really interested in writing this yourself).

This question asks for something similar, with the accepted answer pointing to a bunch of diff related projects . There is a lot of good code written there that is definitely worth looking at.

+1


a source


String.Compare will work. If you want to compare words, then just split the initial string into an array of strings and loop through it.

0


a source







All Articles