A matching key puts variants of a name in the same group without changing what you display.
dotnet add package RecursiveAI.OneContactRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using RecursiveAI.OneContact; var name = PersonName.Parse("Bob Smith"); Console.WriteLine( name.GetKey(KeyVersion.V1));
Unzip the example, then dotnet run.
robert smithFull program
using RecursiveAI.OneContact; string[] names = [ "Bob Smith", "Dr. Robert Smith Jr.", "Robert James Smith", "Robert J. Smith", "Renée O'Brien", "Renee Obrien", "", ]; foreach (string text in names) { if (PersonName.TryParse(text, out var name)) Console.WriteLine($"{text} => {name.GetKey(KeyVersion.V1)}"); else Console.WriteLine("Skipped: empty or unparseable name"); }
dotnet run prints:
Bob Smith => robert smith Dr. Robert Smith Jr. => robert smith Robert James Smith => robert j smith Robert J. Smith => robert j smith Renée O'Brien => renee obrien Renee Obrien => renee obrien Skipped: empty or unparseable name
The full program compares names with titles, initials and accents. If TryParse returns false, it reports the skipped input instead of comparing a default value.
Variations
Known family-name order or structure can change how the parser splits a name. Here the Spanish country hint lets the parser read two family names:
using RecursiveAI.OneContact; var name = PersonName.Parse( "José García López", Region.Parse("ES")); Console.WriteLine(name.GetKey(KeyVersion.V1));
jose garcialopezRelated recipes
- Parse a person name into parts
- Split multiple person names
- Deduplicate contacts by matching name keys in C#
The short answer
In C#, parse the name with PersonName.Parse and call GetKey(KeyVersion.V1). Compare the returned strings ordinally. Bob Smith and Dr. Robert Smith Jr. both give robert smith; a match means the two names landed in the same group, not that the records belong to the same person. Store the original or a separate display name, not the key, for anything a person will read.
Why isn’t exact string matching enough for names?
Even a case-insensitive comparison still sees “Renée O’Brien” and “Renee Obrien” as different strings. The V1 person key folds case, maps Latin letters such as é and ø to e and o, and removes punctuation such as apostrophes and hyphens. It also leaves out titles and suffixes. That makes the key useful when two systems record the same name differently, but also means it cannot recover the original spelling. It isn’t a general transliterator or a fuzzy spelling score.
How do you match names with nicknames and middle initials?
The key maps listed given-name nicknames to a formal name, so “Bob” becomes “Robert”. It keeps the first letter of each middle word, so the full program gives “Robert James Smith” and “Robert J. Smith” the same key. A missing middle name is different: “Robert Smith” stays robert smith, without a j. Short names such as “Sam” and “Chris” aren’t expanded, and the nickname list doesn’t translate names across languages.
Family particles and second family names are folded into the family part without spaces. A hint can help when a source follows a known naming convention. Name hints guide ambiguous splits; they don’t infer a person’s origin. Use the same hints for runs on the same data, since a different split can change the comparison key.
Does a matching name mean two records belong to the same person?
No. Dropping suffixes means a parent and child can have the same key. Two unrelated people can also share the same normalized name, and one person’s names can produce different keys if a middle name is missing or a spelling isn’t covered. Use equal keys to find candidates, then check a reliable record identifier or corroborating contact information before you merge anything. If you persist the key, save its version with it: OneContact keeps each published version’s output stable, so you can compare like with like.