Soenneker.Utils.String.LongestCommonSequence 11.0.1045

Prefix Reserved
dotnet add package Soenneker.Utils.String.LongestCommonSequence --version 11.0.1045
                    
NuGet\Install-Package Soenneker.Utils.String.LongestCommonSequence -Version 11.0.1045
                    
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="11.0.1045" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.String.LongestCommonSequence" Version="11.0.1045" />
                    
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 11.0.1045
                    
#r "nuget: Soenneker.Utils.String.LongestCommonSequence, 11.0.1045"
                    
#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@11.0.1045
                    
#: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=11.0.1045
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.String.LongestCommonSequence&version=11.0.1045
                    
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 net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net11.0

    • No dependencies.

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
11.0.1045 92 11/18/2026
11.0.1044 81 11/18/2026
11.0.1043 83 11/18/2026
11.0.1041 728 10/27/2026
11.0.1040 107 10/26/2026
11.0.1039 100 10/26/2026
4.0.1038 110 10/25/2026
4.0.1037 134 10/14/2026
4.0.1036 108 10/14/2026
4.0.1030 107 10/13/2026
4.0.1028 128 10/11/2026
4.0.1027 163 9/24/2026
4.0.1026 136 9/15/2026
4.0.1025 122 9/14/2026
4.0.1024 136 9/8/2026
4.0.1023 140 8/30/2026
4.0.1022 137 8/26/2026
4.0.1021 142 8/12/2026
4.0.1020 137 7/27/2026
4.0.1019 7,136 7/16/2026
Loading failed

Configure .NET CI defaults and daily source scans