Format string to a 3 digit number

前端 未结 9 1342
说谎
说谎 2020-12-15 02:07

Instead of doing this, I want to make use of string.format() to accomplish the same result:

if (myString.Length < 3)
{
    myString =  \"00\"         


        
9条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 02:44

    This is how it's done using string interpolation C# 7

    $"{myString:000}"
    

提交回复
热议问题