formatting string in MVC /C#

后端 未结 10 1937
不知归路
不知归路 2021-02-19 03:15

I have a string 731478718861993983 and I want to get this 73-1478-7188-6199-3983 using C#. How can I format it like this ?

Thanks.

10条回答
  •  盖世英雄少女心
    2021-02-19 03:54

    string myString = 731478718861993983;
    myString.Insert(2,"-");
    myString.Insert(7,"-");
    myString.Insert(13,"-");
    myString.Insert(18,"-");
    

提交回复
热议问题