Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6152621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:57:03+00:00 2026-05-23T19:57:03+00:00

Well i want to compare 2 strings (version one and version two) and get

  • 0

Well i want to compare 2 strings (version one and version two) and get the differences in a format that i can convert to html on my own, like you can view how a post was edited here on stackoverflow or like svn tracks differences between revisions….

It must be full managed code library.

Like this JavaScript but i need to do it on the server-side..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:57:04+00:00Added an answer on May 23, 2026 at 7:57 pm

    I have a class library that does this, I’ll post a link below, but I’ll also post how it does its job so that you can evaluate whether it will be fitting for your content.

    Note that for everything I say below, if you think of each character as an element of a collection, you can implement the algorithm described below for any type of content. Be it characters of a string, lines of text, collections of ORM-objects.

    The whole algorithm revolves around longest-common-substring (LCS), and is a recursive approach.

    First the algorithm tries to find the LCS between the two. This will be the longest section that is unchanged/identical between the two versions. The algorithm then considers these two parts to be “aligned”.

    For instance, here’s how two example strings would be aligned:

          This long text has some text in the middle that will be found by LCS
    This extra long text has some text in the middle that should be found by LCS
              ^-------- longest common substring --------^
    

    Then it recursively applies itself to the portions before the aligned section, and the portion afterwards.

    The final “result” could look like this (I’m using the underscore to indicate portions “not there” in one of the strings):

    This ______long text has some text in the middle that ______will be found by LCS
    This extra long text has some text in the middle that should____ be found by LCS
    

    Then, as part of the recursive approach, each level of recursive call will return a collection of “operations”, which based on whether there’s a LCS, or missing portions in either part, will spit out as follows:

    • If LCS, then it is a “copy” operation
    • If missing from first, then it is a “insert” operation
    • If missing from second, then it is a “delete” operation

    So the above text would be:

    1. Copy 5 characters (This)
    2. Insert extra_ (apparently code-blocks here remove space, the underscore is a space)
    3. Copy 43 characters (long text has some text in the middle that_)
    4. Insert should
    5. Delete 4 characters (will)
    6. Copy 16 characters (_be found by LCS)

    The core of the algorithm is quite simple, and with the above text, you should be able to implement it yourself, if you want to.

    There are some extra features in my class library, in particular to handle such things as content that is similar to the changed text, so that you don’t just get delete or insert operations, but also modify operations, this will mostly be important if you’re comparing a list of something, like lines from text files.

    The class library can be found here: DiffLib on GitHub, and you will also find it on Nuget for easy installation in Visual Studio 2010. It is written in C# for .NET 3.5 and up, so it will work for .NET 3.5 and 4.0, and since it is a binary release (all source code is on GitHub though), you can use it from VB.NET as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well the title is quite self explanatory. I want to build two panels one
I want to compare two binary files. One of them is already stored on
Does anyone have code to compare two version numbers in JavaScript? I just want
I want to compare two dates in PHP. One date is the date due,
I want to be able to read any well-formed RSS/ATOM file. That would mean
Say I have a unit test that wants to compare two complex for objects
How can I Compare values of two arrays to check if 1 array does
I want to compare a list of lists that have the same length, but
I have a birth_date variable in the Date format. I want to compare it
How do you compare strings so that the comparison is true only if the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.