Norske fødselsnummer i C# / Norwegian national ID numbers in C#

Available as NuGet package: https://www.nuget.org/packages/Tedd.Fodselsnummer

Code to verify Norwegian national id number (fødselsnummer / personnummer) written in C#.

Obeys 2013 standards as described in this Wikipedia article. Please let me know how if you find bugs / improvements. 🙂

(PS: This code is easy to test in LINQPad. Select C# Program, paste it in and hit run.)

4 thoughts on “Norske fødselsnummer i C# / Norwegian national ID numbers in C#”

  1. Hi Tedd,

    I am trying to apply similar logic to a Teradata SQL query. What I am trying to find out is how the 2nd checksum is calculated if the 1st produces an “X” i.e. the first checksum was 10 which is replaced with an “X” (according to several sources in Wiki, Google etc).

    e.g.

    181251490 becomes 122 when multiplying each digit by the weight and adding the result.

    122/11 = 11 remainder 1

    11-1 = 10

    Check digit is therefore X

    181251490 becomes 181251490X

    So I need to understand how to use mod11 on 181251490X

    (one source: <a href="http://www.pgrocer.net/Cis51/mod11.html" rel="nofollow ugc">http://www.pgrocer.net/Cis51/mod11.html</a>)

    Thanks,
    Jonny

    Reply
    • Hi

      For Norwegian birth numbers there is no X, only digits. If the mod11 result is 11 its changed to 0, if result is 10 then number is invalid. Second control digit follows the same rule with multipliers vs indexes changed.

      Br,
      Tedd

      Reply
  2. Thank you, I was looking for test data, and oddly enough could not find it anywhere else.
    Long shot: Do you know where to find company numbers?

    /Terje

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Tedds blog

Subscribe now to keep reading and get access to the full archive.

Continue reading