Mask
Replaces all but the last n characters in a string with the specified mask character.
- Use
string.Substring()to get the lastncharacters of the passed string,str. - Use
string.PadLeft()to add as manymaskcharacters 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 of4characters unmasked.