I have a card number as a string, for example:
string ClsCommon.str_CardNumbe r = \"3456123434561234\";
The length of this card number can
I'm sure there is a cleaner way to do this:
int currentChar = 0;
string maskable = "11111144441111";
string masked = maskable;
int length = masked.Length;
int startMaskPoint = 6;
int endMaskPoint = length - 4 - startMaskPoint;
masked = masked.Remove(startMaskPoint, endMaskPoint);
int numRemoved = length - masked.Length;
string Mask = "";
while (numRemoved != 0)
{
Mask = Mask + "#";
numRemoved--;
}
masked = masked.Insert(startMaskPoint, Mask);
string returnableString = masked;
while (length > 4)
{
returnableString = returnableString.Insert(currentChar + 4, " ");
currentChar = currentChar + 5;
length = length - 4;
}