Reputation: 15715
Do you know of any library written in C# or compiled for .NET that I can use to find the differences between two strings (what have been inserted and what have been deleted) and then use this difference to revert the text to the original state (instead of having to save a copy of the original text)?
Upvotes: 2
Views: 1285
Reputation: 131756
What you're looking for is something that solves the Longest Common Subsequence problem. There are commercial libraries that implement that, but you can find a free version that you may be able to use or adapt on CodeProject: http://www.codeproject.com/KB/recipes/DiffAlgorithmCS.aspx.
If you're interested in the core implementation of such an algorithm, you can also find it on Wiki Books Algorithms.
Upvotes: 2
Reputation: 17196
You should learn about source control, which gives you this feature as part of a system that does what you are asking for.
Subversion is easy to understand, and its windows client is user friendly.
Recently I started using Git because it seemed interesting, and I like the way it works for teams.
Also, WinMerge is a tool that does what you want outside the context of SCM.
Upvotes: 0
Reputation: 3366
Are you basically looking for something like a diff utility, but in C#?
You can try to adapt one of these:
http://www.codeproject.com/KB/cs/differ.aspx
http://www.codeproject.com/KB/files/CsLCSDiff.aspx
http://www.codeproject.com/KB/recipes/diffengine.aspx
Upvotes: 1