Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string getEAN13CheckSum(string valore)
- {
- int iSum = 0;
- int iDigit = 0;
- // Calculate the checksum digit here.
- for( int i = valore.Length; i >= 1; i-- )
- {
- iDigit = Convert.ToInt32( valore.Substring( i - 1, 1 ) );
- if( i % 2 == 0 )
- { // odd
- iSum += iDigit * 3;
- }
- else
- { // even
- iSum += iDigit * 1;
- }
- }
- int iCheckSum = ( 10 - ( iSum % 10 ) ) % 10;
- return iCheckSum.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment