[Solved] how to show only the last four digit of a credit card number [duplicate]


You can use a combination of String.Substring and String.Format.


Example:

var card_number = "1234384234034";
var reason = "some reason";
var s = "Received returned card ending in {0} due to {1} will dispose off after 45 days";
var text = String.Format(s, card_number.Substring(card_number.Length-4), reason);

Output:

Received returned card ending in 4034 due to some reason will dispose off after 45 days

1

solved how to show only the last four digit of a credit card number [duplicate]