CardNumber

Field: static readonly CardNumber Empty

It is the blank card number.


Method: static CardNumber Parse(String)

Takes the card number of the string type and creates the CardNumber object after verifying the card number.

Warning 1: The spaces in the card number are ignored.

    CardNumber parsedCardNumber = CardNumber.Parse("1234 1234 1234 1234");

WARNING 2: If the card number is 8 digits, "???? ????" is inserted at the beginning of the created CardNumber object.

    CardNumber parsedCardNumber = CarNumber.Parse("1234 1234"); //Value of CardNumber object : "???? ???? 1234 1234"
Parameter Name Description
cardNumberString Card number in string type

Error Type: FormatException (If the card number has a non-numeric value or is not 8 or 16 characters, it is discarded.)


Constructor(Int32)

CardNumber object is created with data of type int.

Parameter Name Description
intValue CardNumber of type int

Property: string Value

Invokes the ToString method and returns the result.


Method: string ToString()

The data is returned as unformatted and unmasked string.

    12341234 or 1234123412341234

Method: string ToString(Boolean)

The data is returned as unmasked string.

    1234 1234 or 1234 1234 1234 1234 //formatted
    12341234 or 1234123412341234 //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)

Veriyi string tipinde döner. The data is returned as a type string

    1234 1234 or 1234 1234 1234 1234 //formatted and unmasked
    12341234 ya da 1234123412341234 //unformated and unmasked

    xxxx xxxx or xxxx xxxx xxxx xxxx //formatted and masked
    xxxxxxxx or xxxxxxxxxxxxxxxx //unformatted and masked
Parameter Name Description
format If true, the return value returns a space between each 4 digits. If false, the data is returned without spaces
unmask If true, the card number is clear. If false, the card number is masked with the character 'x'

Property: bool IsComplete

Returns true if the length is 16 characters and false if the length is less than 16 characters.

    CardNumber.Parse("02928157").Complete("14013008").IsComplete;

Method: CardNumber Complete(String)

CardNumber verisinin karakter sayısını, prefix ekleyerek 16'ya tamamlar. Completes the number of characters of CardNumber data to 16 by adding prefix.

    CardNumber.Parse("02928157").Complete("14013008");
Parameter Name Description
prefix This is the number to add before the card number. It must be numeric.

Property: string[] Parts

Returns the string Array by grouping the four characters of the card number.

IsComplete returns an array containing the last 8 digits for card numbers with false values.


Property: string[] PartsExceptLast

Returns the elements of the Parts property that are not the last element.


Property: string Part1

The first 4 digits of the card number return.


Property: string Part2

The second 4 digits of the card number return.


Property: string Part3

The third 4 digits of the card number return.


Property: string Part4

The fourth 4 digits of the card number return.


Property: string Half1

The first 8 digits of the card number return.


Property: string Half2

The last 8 digits of the card number return.


Property: int Half2AsInt

The last 8 characters of the card number return int type.

If the last 8 digits are the default value (--------), it returns 0


Method: object Clone()

Creates a new object with the data of type CardNumber and returns the created object in object type.


Method: bool Equals(Object)

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

Parameter Name Description
obj Object to be compared

Method: bool Equals(CardNumber)

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

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