Class Luhn
Provides extension methods for computing and validating Luhn check digits.
public static class Luhn
- Inheritance
-
Luhn
- Inherited Members
Methods
AppendCheckDigit(IList<int>)
Appends the Luhn check digit to the end of a list of digits.
public static IList<int> AppendCheckDigit(this IList<int> digits)
Parameters
Returns
AppendCheckDigit(int)
Appends the Luhn check digit to an integer by multiplying by 10 and adding the check digit.
public static int AppendCheckDigit(this int digits)
Parameters
digitsintThe integer value.
Returns
- int
The integer with the check digit appended as the last digit.
AppendCheckDigit(long)
Appends the Luhn check digit to a long integer by multiplying by 10 and adding the check digit.
public static long AppendCheckDigit(this long digits)
Parameters
digitslongThe long integer value.
Returns
- long
The long integer with the check digit appended as the last digit.
AppendCheckDigit(string)
Appends the Luhn check digit to the end of a string of digit characters.
public static string AppendCheckDigit(this string digits)
Parameters
digitsstringThe string of digit characters.
Returns
- string
The original string with the check digit appended.
CheckDigit(IList<int>)
Computes the Luhn check digit for a list of digits.
public static int CheckDigit(this IList<int> digits)
Parameters
Returns
- int
The computed Luhn check digit.
CheckDigit(int)
Computes the Luhn check digit for an integer value.
public static int CheckDigit(this int digits)
Parameters
digitsintThe integer value to compute the check digit for.
Returns
- int
The computed Luhn check digit.
CheckDigit(long)
Computes the Luhn check digit for a long integer value.
public static int CheckDigit(this long digits)
Parameters
digitslongThe long integer value to compute the check digit for.
Returns
- int
The computed Luhn check digit.
CheckDigit(string)
Computes the Luhn check digit for a string of digit characters.
public static string CheckDigit(this string digits)
Parameters
digitsstringThe string of digit characters to compute the check digit for.
Returns
- string
The computed Luhn check digit as a string.
HasValidCheckDigit(IList<int>)
Validates whether the last digit in the list is a valid Luhn check digit.
public static bool HasValidCheckDigit(this IList<int> digits)
Parameters
Returns
- bool
True if the check digit is valid; otherwise, false.
HasValidCheckDigit(int)
Validates whether the last digit of the integer is a valid Luhn check digit.
public static bool HasValidCheckDigit(this int digits)
Parameters
digitsintThe integer value including the check digit as the last digit.
Returns
- bool
True if the check digit is valid; otherwise, false.
HasValidCheckDigit(long)
Validates whether the last digit of the long integer is a valid Luhn check digit.
public static bool HasValidCheckDigit(this long digits)
Parameters
digitslongThe long integer value including the check digit as the last digit.
Returns
- bool
True if the check digit is valid; otherwise, false.
HasValidCheckDigit(string)
Validates whether the last character in the string is a valid Luhn check digit.
public static bool HasValidCheckDigit(this string digits)
Parameters
digitsstringThe string of digit characters including the check digit as the last character.
Returns
- bool
True if the check digit is valid; otherwise, false.