public static String CreateMaskedValue(string valueForMask, Int32 numberOfCharacter)
{
String maskedString = String.Empty;
int remainingCharCount = (valueForMask.Length - numberOfCharacter) < 0 ? valueForMask.Length : valueForMask.Length - numberOfCharacter;
if (remainingCharCount > 0)
{
if (!string.IsNullOrEmpty(valueForMask))
{
if (valueForMask.Length > 0)
{
maskedString = string.Concat("".PadLeft(numberOfCharacter, 'x'), valueForMask.Substring(valueForMask.Length - remainingCharCount));
}
}
return maskedString;
}
else
return valueForMask;
}
{
String maskedString = String.Empty;
int remainingCharCount = (valueForMask.Length - numberOfCharacter) < 0 ? valueForMask.Length : valueForMask.Length - numberOfCharacter;
if (remainingCharCount > 0)
{
if (!string.IsNullOrEmpty(valueForMask))
{
if (valueForMask.Length > 0)
{
maskedString = string.Concat("".PadLeft(numberOfCharacter, 'x'), valueForMask.Substring(valueForMask.Length - remainingCharCount));
}
}
return maskedString;
}
else
return valueForMask;
}
No comments:
Post a Comment