[Solved] How to mask first two letter and last four letters of credit card number [closed]


You need to cut the text in the string after the first two characters and up to the last four, and then put two asterisks in front and four at the end.

Substring() is an excellent string function for this, combinef with knowing the length of the string, which Length will give you. Thus, a working code snippet would be:

var middle = s.Substring(2, s.Length - 2 - 4);
var result = string.Format("**{0}****", middle);

3

solved How to mask first two letter and last four letters of credit card number [closed]