What will be the equivalent code for Format(iCryptedByte, "000") (VB.NET) in C# ?
Asked
Active
Viewed 1.2k times
8
Kiquenet
- 13,820
- 33
- 141
- 236
6 Answers
2
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.
Peet Brits
- 2,325
- 24
- 46
1
Microsoft.VisualBasic.Strings.Format(iCryptedByte, "000");
You'll need to add a reference to the Microsoft.VisualBasic assembly.
José Margaça Lopes
- 119
- 5
1
Given this VB code:
Strings.Format(iCryptedByte, format)
Replace with this C# code:
var csformat = "{0:" + format + "}";
String.Format(csformat, iCryptedByte);
xagyg
- 9,304
- 2
- 29
- 28
0
Try:
iCryptedByte.ToString("D3");
Paul Michaels
- 15,217
- 40
- 143
- 262
-
Depends on `iCryptedByte` type. if it's `int` - yes, `ToString(string)` exists – abatishchev Jul 21 '10 at 07:08