Symeon Laftsopoulos Symeon Laftsopoulos - 2 months ago 15x
C# Question

C# Append Text with Specific text format

So guyz , I use a classic StringBuilder to create some text so I can "Append" it to a text file.
Everything works fine but I need the text file to have a specific look so i need a price(for example 32) to be shown as ( 00032.0000 ) .
To make the "32" show up in the TxT file I use this code.

calcprice = Convert.ToInt32(printquant) * Convert.ToInt32(dataGridView2.Rows[counter4].Cells[category].Value);
printprice = calcprice.ToString();


you can use the built in ToString formatter

int printPrice = 32;
printPrice.ToString("00000.0000") //-> 00032.0000