在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
View Code
/// <summary> /// 每隔n个字符插入一个字符 /// </summary> /// <param name="input">源字符串</param> /// <param name="interval">间隔字符数</param> /// <param name="value">待插入值</param> /// <returns>返回新生成字符串</returns> public static string InsertFormat(string input, int interval, string value) { for (int i = interval; i < input.Length; i += interval + 1) input = input.Insert(i, value); return input; } //用例 public static void Main() { string stest= "EMKEMEMM3335368CKGE43MI3"; Console.WriteLine( InsertFormat(stest,4,"-")); // "EMKE-MEMM-3335-368C-KGE4-3MI3" Console.ReadKey(); }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论