Equivalent of Format of VB in C#
-
18-09-2020 - |
문제
What will be the equivalent code for Format(iCryptedByte, "000")
(VB.NET) in C# ?
해결책
Try:
iCryptedByte.ToString("D3");
다른 팁
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);
see String.Format
Microsoft.VisualBasic.Strings.Format(iCryptedByte, "000");
You'll need to add a reference to the Microsoft.VisualBasic assembly.
제휴하지 않습니다 StackOverflow