简体   繁体   中英

Equivalent of Format of VB in C#

C#中Format(iCryptedByte, "000") (VB.NET)的等效代码是什么?

String.Format(format, iCryptedByte); // where format like {0:D2}

见MSDN 123

Another very useful site for C# string formatting: http://blog.stevex.net/string-formatting-in-csharp/

Instead of {0:D3} you can also use the zero placeholder, eg {0:000} will pad with zeros to minimum length of three.

Given this VB code:

Strings.Format(iCryptedByte, format)

Replace with this C# code:

var csformat = "{0:" + format + "}";
String.Format(csformat, iCryptedByte);

请参阅String.Format

尝试:

iCryptedByte.ToString("D3");
Microsoft.VisualBasic.Strings.Format(iCryptedByte, "000");

您需要添加对Microsoft.VisualBasic程序集的引用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM