Mask
Replaces all but the last n
characters in a string with the specified mask
character.
- Use
string.Substring()
to get the lastn
characters of the passed string,str
. - Use
string.PadLeft()
to add as manymask
characters as necessary to the start of the string to return a string of the same length. - Omit the third argument,
mask
, to use a default character of'*'
. - Omit the second argument,
n
, to keep a default of4
characters unmasked.