开发者

Equivalent of Format of VB in C#

开发者 https://www.devze.com 2023-01-08 17:28 出处:网络
What will be the equivalent code for 开发者_开发技巧Format(iCryptedByte, \"000\") (VB.NET)in C# ?String.Format(format, iCryptedByte); // where format like {0:D2}

What will be the equivalent code for 开发者_开发技巧Format(iCryptedByte, "000") (VB.NET) in C# ?


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

See MSDN 1, 2, 3


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, e.g. {0:000} will pad with zeros to minimum length of three.


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

You'll need to add a reference to the Microsoft.VisualBasic assembly.


Given this VB code:

Strings.Format(iCryptedByte, format)

Replace with this C# code:

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


Try:

iCryptedByte.ToString("D3");


see String.Format

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号