I have a card number as a string, for example:
string ClsCommon.str_CardNumbe r = \"3456123434561234\";
The length of this card number can
Linq saves coding lines, small code snippet.
Replaces with (*) char above 6 and bellow CardPan length minus 4
var CardPan = "1234567890123456";
var maskedPan = CardPan.Aggregate(string.Empty, (value, next) =>
{
if (value.Length >= 6 && value.Length < CardPan.Length - 4)
{
next = '*';
}
return value + next;
});