G
Guest
Hi, I'm maintaining C# code and am fairly new with C# programming. I'm
looking for codes that's droping the 2nd digit of a nuber printed out and I
suspect it's the code below. Can someone tell me where I can look up
explaination on the String.Format, the format string part like "("{0:.#0}".
What's the trailing 0 and what is that "0:" means? I assume the "#" is the
place holder character for th value obtain after the comma in the code.
Thanks, Alpha
string amountdecimal =
String.Format("{0:.#0}",Convert.ToDecimal(drTrips.Row["Amount"]) - (int)
Convert.ToDecimal(drTrips.Row["Amount"]));
if(amountdecimal.StartsWith("-"))
{
amountdecimal = amountdecimal.Substring(1,amountdecimal.Length-1);
}
amount = String.Format("{0,9:####,##0}",(int)
Convert.ToDecimal(drTrips.Row["Amount"])) + " " +
amountdecimal.Substring(1,2);
looking for codes that's droping the 2nd digit of a nuber printed out and I
suspect it's the code below. Can someone tell me where I can look up
explaination on the String.Format, the format string part like "("{0:.#0}".
What's the trailing 0 and what is that "0:" means? I assume the "#" is the
place holder character for th value obtain after the comma in the code.
Thanks, Alpha
string amountdecimal =
String.Format("{0:.#0}",Convert.ToDecimal(drTrips.Row["Amount"]) - (int)
Convert.ToDecimal(drTrips.Row["Amount"]));
if(amountdecimal.StartsWith("-"))
{
amountdecimal = amountdecimal.Substring(1,amountdecimal.Length-1);
}
amount = String.Format("{0,9:####,##0}",(int)
Convert.ToDecimal(drTrips.Row["Amount"])) + " " +
amountdecimal.Substring(1,2);