I have a card number as a string, for example:
string ClsCommon.str_CardNumbe r = \"3456123434561234\";
The length of this card number can
Try this one. Simple and straight forward.
public static class StringExtensions
{
public static string Masked(this string source, int start, int count)
{
return source.Masked('x', start, count);
}
public static string Masked(this string source, char maskValue, int start, int count)
{
var firstPart = source.Substring(0, start);
var lastPart = source.Substring(start + count);
var middlePart = new string(maskValue, count);
return firstPart + middlePart + lastPart;
}
}