1 /// <summary>
2 /// 替换*号
3 /// </summary>
4 /// <param name="value">字符串</param>
5 /// <param name="startLen">前几位字符不替换</param>
6 /// <param name="endLen">后几位字符不提货</param>
7 /// <param name="specialChar">需要替换的字符</param>
8 /// <returns></returns>
9 public static string ReplaceWithSpecialChar(string value, int startLen = 4, int endLen = 4, char specialChar = '*')
10 {
11 try
12 {
13 int lenth = value.Length - startLen - endLen;
14 string replaceStr = value.Substring(startLen, lenth);
15 string specialStr = string.Empty;
16 for (int i = 0; i < replaceStr.Length; i++)
17 {
18 specialStr += specialChar;
19 }
20 value = value.Replace(replaceStr, specialStr);
21 }
22 catch (Exception)
23 {
24 throw;
25 }
26 return value;
27 }