Equivalent of Format of VB in C#

南楼画角 提交于 2019-12-01 16:47:20

Try:

iCryptedByte.ToString("D3");
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.

Given this VB code:

Strings.Format(iCryptedByte, format)

Replace with this C# code:

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!