I have a 4 byte value that I convert to an Int32 and then display it in a textbox. No problems there. The problem comes in when I try padding the string with 0's. When I display the decimal number it should always contain 8 characters, so if its less than that I want to pad it with 0's.
string parmDecString = BitConverter.ToInt32(testNum, 0).ToString();
Console.WriteLine("length: {0} - {1}", parmDecString.Length, (8 - parmDecString.Length));
for (int l=0; l < (8-parmDecString.Length); l++)
{
parmDecString = "0" + parmDecString;
}
textBox74.Text = parmDecString;
Here's the output in the textbox I get based on different 'parmDecString' values:
parmDecString = "123"
Console: length: 3 - 5
textbox: 000123 <=== only 3 times in the 'for' loop, expected 5x
parmDecString = "12345"
Console: length: 5 - 3
textbox: 0012345 <=== only 2 times in the 'for' loop, expected 3x
parmDecString = "12345678"
Console: length: 8 - 0
textbox: 12345678 <=== as expected