Search Results

Search found 1 results on 1 pages for 'user518307'.

Page 1/1 | 1 

  • How do I check the validity of the Canadian Social Insurance Number in C#?

    - by user518307
    I've been given the assignment to write an algorithm in C# that checks the validity of a Canadian Social Insurance Number (SIN). Here are the steps to validate a SIN. Given an example Number: 123 456 782 Remove the check digit (the last digit): 123456782 Extract the even digits (2,4,6,8th digith): 12345678 Double them: 2 4 6 8 | | | | v v v v 4 8 12 16 Add the digits together: 4+8+1+2+1+6 = 22 Add the Odd placed digits: 1+3+5+7 = 16 Total : 38 Validity Algorithm If the total is a multiple of 10, the check digit should be zero. Otherwise, Subtract the Total from the next highest multiple of 10 (40 in this case) The check digit for this SIN must be equal to the difference of the number and the totals from earlier (in this case, 40-38 = 2; check digit is 2, so the number is valid) I'm lost on how to actually implement this in C#, how do I do this?

    Read the article

1