Soenneker.Utils.String.LongestCommonSequence 4.0.1024

Prefix Reserved
dotnet add package Soenneker.Utils.String.LongestCommonSequence --version 4.0.1024
                    
NuGet\Install-Package Soenneker.Utils.String.LongestCommonSequence -Version 4.0.1024
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Utils.String.LongestCommonSequence" Version="4.0.1024" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.String.LongestCommonSequence" Version="4.0.1024" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.String.LongestCommonSequence" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Utils.String.LongestCommonSequence --version 4.0.1024
                    
#r "nuget: Soenneker.Utils.String.LongestCommonSequence, 4.0.1024"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Utils.String.LongestCommonSequence@4.0.1024
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Utils.String.LongestCommonSequence&version=4.0.1024
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.String.LongestCommonSequence&version=4.0.1024
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.String.LongestCommonSequence

Longest common subsequence scoring for strings, with normalized and percentage results.

Installation

dotnet add package Soenneker.Utils.String.LongestCommonSequence

Usage

using Soenneker.Utils.String.LongestCommonSequence;

var text1 = "This is a test";
var text2 = "This is another test";

double score = LcsStringUtil.CalculateSimilarity(text1, text2);
double percentage = LcsStringUtil.CalculateSimilarityPercentage(text1, text2);

// score == 0.7
// percentage == 70

The longest common subsequence preserves character order but does not require matching characters to be adjacent. The normalized score is:

LCS length / length of the longer input

CalculateSimilarity returns a value from 0 to 1; CalculateSimilarityPercentage multiplies it by 100. Identical strings, including two empty strings, return 1 (or 100%).

Comparison rules and cost

  • Comparison is case-sensitive.
  • The algorithm compares UTF-16 code units, not words, Unicode scalar values, or grapheme clusters.
  • Whitespace and punctuation participate like any other character.
  • Runtime is O(m × n) for input lengths m and n.
  • CalculateSimilarity uses O(min(m, n)) working memory.

For long inputs, the quadratic runtime can be significant. Normalize casing or Unicode representation before calling when your application requires those equivalences.

Prefix lengths

CalculateSimilarityArray(first, second) exposes the final dynamic-programming row. Element j contains the LCS length between first and the first j characters of second; the returned array therefore has second.Length + 1 elements. Use its last element for the complete LCS length.

All methods require non-null strings.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1024 40 9/8/2026
4.0.1023 94 8/30/2026
4.0.1022 95 8/26/2026
4.0.1021 105 8/12/2026
4.0.1020 110 7/27/2026
4.0.1019 261 7/16/2026
4.0.1018 109 7/14/2026
4.0.1017 164 6/18/2026
4.0.1016 160 6/9/2026
4.0.1014 132 5/12/2026
4.0.1013 123 4/23/2026
4.0.1012 120 4/21/2026
4.0.1011 132 4/14/2026
4.0.1010 137 3/12/2026
4.0.1005 135 3/10/2026
4.0.1004 125 3/10/2026
4.0.1003 126 3/9/2026
4.0.1002 123 3/9/2026
4.0.1001 115 3/4/2026
4.0.1000 136 2/10/2026
Loading failed

Update dependency Microsoft.Extensions.DependencyInjection.Abstractions to 10.0.12 (#1587)