开发者

Find text differences in C# and use them to revert text to previous state

Do you know of any library written in C开发者_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)?


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜