What will be the equivalent code for Format(iCryptedByte, "000")
(VB.NET) in C# ?
Asked
Active
Viewed 1.3k times
8

Kiquenet
- 14,494
- 35
- 148
- 243
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,911
- 1
- 31
- 47
1
Microsoft.VisualBasic.Strings.Format(iCryptedByte, "000");
You'll need to add a reference to the Microsoft.VisualBasic assembly.

José Margaça Lopes
- 139
- 6
1
Given this VB code:
Strings.Format(iCryptedByte, format)
Replace with this C# code:
var csformat = "{0:" + format + "}";
String.Format(csformat, iCryptedByte);

xagyg
- 9,562
- 2
- 32
- 29
0
Try:
iCryptedByte.ToString("D3");

Paul Michaels
- 16,185
- 43
- 146
- 269
-
Depends on `iCryptedByte` type. if it's `int` - yes, `ToString(string)` exists – abatishchev Jul 21 '10 at 07:08