方法一:

            string str = 123456789;
            str = int.Parse(str).ToString("##-###-####");
方法二:
            string str = "123456789";
            str = str.Insert(5,"-");
            str = str.Insert(2, "-");
方法三:
首先引入命名空间:using System.Text.RegularExpressions
            //Regex reg = new Regex(@"^(\d{2})(\d{3})(\d{4})$");
或者
            Regex reg = new Regex(@"^(\d{2})(\d{3})(\d{4})$");
            str = reg.Replace(str,"$1-$2-$3");

相关文章:

  • 2021-12-16
  • 2021-11-27
  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
  • 2021-08-30
  • 2021-05-20
猜你喜欢
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案