• Code
  • Tags
  • Users
  • Titles
  • Log in
  • Feedback
  • FAQ
Share Code
Welcome to ForkCan.com

ForkCan is all about sharing code in a social way.

Discuss, debate or argue with other devs about their or your own code.

Give other devs feedback or make a Fork (Make a better version of a shared code).

Rate the code, if you use the code mark it as used so others can see if the shared code is used by someone.

Help each other to be better devs and to be more productive.


Features not working yet:

Flag a post


QR Code

Tiny Url

http://4kcan.com/s/MTAzMg==

Related Code
Check if the Civic Registration number for Norway is valid

Check if the Civic Registration number for Finland is valid


0
570 0 0 0 0 0

    private static readonly string[] FiCheckChars = new string[] {"0","1","2","3","4","5","6","7","8",
                                                                  "9","a","b","c","d","e","f","h",
                                                                  "j","k","l","m","n","p","r",
                                                                  "s","t","u","v","w","x","y"};

    public bool IsCivicRegistrationNumberValid(string civicNumber)
    {
        if (civicNumber == null)
            return false;

        var cleanedCivicNumber = civicNumber.Replace("-", "");

        if (cleanedCivicNumber.Length != 10)
            return false;

        if (!IsDateValid(cleanedCivicNumber.Substring(0, 6), "ddMMyy", "fi-FI"))
            return false;

        // Valid check character? 
        var vNr = double.Parse(cleanedCivicNumber.Substring(0, cleanedCivicNumber.Length - 1));
        var vCheck = (int)(vNr % 31);
        var letterCheck = cleanedCivicNumber.ToLower().Substring(cleanedCivicNumber.Length - 1);

        return FiCheckChars[vCheck] == letterCheck;
    }

Share: twitter | facebook   Action: used | fork | flag

c#

Mark 'c#' tag as 'like'

Mark 'c#' tag as 'ignore'

civicregnumber

Mark 'civicregnumber' tag as 'like'

Mark 'civicregnumber' tag as 'ignore'


 Tommy
200
December 09, 2011 8:25 AM

Fork

 Check if the Civic Registration number for Finland is valid - Tommy Friday 09, 2011 8:25 AM


0 Feedback


You must log in before you can give any feedback


0 Discussion(s)

Newest Oldest

You must log in before you can post a comment

Squeed
Made by: Fredrik Normén 2010