CreditCardNumber

Field: static readonly CreditCardNumber Empty

It's an empty CreditCardNumber object. The credit card number does not stored.


Method: static CreditCardNumber Parse(String)

It is the method that creates the CreditCardNumber object with the credit card number. The credit card number must be suitable for the Luhn algorithm.

The gaps in the credit card number are ignored.

The length of the credit card number must be 15 or 16 characters long.

    CreditCardNumber creditCardNumber = CreditCardNumber.Parse("5105105105105100");
Parameter Name Description
creditCardNumberString Credit card number in string type

Error Type: FormatException (This error is thrown if credit card number has a non-numeric value or is not 15 or 16 characters log.)


Property: string Value

The data is returned in string type as unformatted and unmasked

    378282246310005 or 5105105105105100 //unformatted and unmasked

Method: string ToString()

The data is returned in string type as unformatted and unmasked

    378282246310005 or 5105105105105100 //unformatted and unmasked

Method: string ToString(Boolean)

The data is returned in string type as masked('x')

    xxxx xxxx xxxx xxx or xxxx xxxx xxxx xxxx //formatted
    xxxxxxxxxxxxxxx or xxxxxxxxxxxxxxxx //unformatted
Parameter Name Description
format If true, the data returns by putting a space between each 4 digits. If false, the characters are returned without spaces.

Method: string ToString(Boolean, Boolean)

The data is returned in string type.

    3782 8224 6310 005 or 5105 1051 0510 5100 //formatted and unmasked
    378282246310005 or 5105105105105100 //unformatted and unmasked

    xxxx xxxx xxxx xxx or xxxx xxxx xxxx xxxx //formatted and masked
    xxxxxxxxxxxxxxx or xxxxxxxxxxxxxxxx //unformatted and masked
Parameter Name Description
format If true, the data returns by putting a space between each 4 digits. If false, the characters are returned without spaces.
unmask If true, the credit card number is clear. If false, the credit card number is masked with the character 'x'

Method: bool Equals(Object)

Returns true if the given object has the same value as the CreditCardNumber object and the data, false otherwise.

Parameter Name Description
obj Object to be compared

Method: bool Equals(CreditCardNumber)

Returns true if the given CreditCardNumber object has the same value as the data, false otherwise.

Parameter Name Description
other The object of type CreditCardNumber to be compared