Download Diff2.zip - 7.82 KB
Have you ever wanted or needed a diff utility optimized for the .NET platform.
This article provides an implementation of a diff utility written in C#.
It operates over generics, so you can provide lists of anything to be diffed or patched,
including strings (such as lines from files), int, objects, or even bytes.
Example of using the Diff class to diff 2 text files
List<string> a = new List<string>();
List<string> b = new List<string>();
StreamReader fs1 = new StreamReader(argv);
StreamReader fs2 = new StreamReader(argv);
while ((line = fs1.ReadLine()) != null)
while ((line = fs2.ReadLine()) != null)
Item diff_items = Diff2.Diff<string>(a.ToArray(), b.ToArray());
This performs the diff. The final parameter indicates whether the actual differences should be included in the edit script when the diff is performed.