Format Float

  • Thread starter Thread starter O-('' Q)
  • Start date Start date
O

O-('' Q)

Is there an equivalent to Delphi's FormatFloat() function in C#.NET? I
am using VS2005 and can't find any good resources on this type of
function. Everything leads to a dead end so far.

Thanks for any help.

-- Kirby
 
O-('' Q) said:
Is there an equivalent to Delphi's FormatFloat() function in C#.NET? I
am using VS2005 and can't find any good resources on this type of
function. Everything leads to a dead end so far.

It would be helpful if you'd say what FormatFloat does in Delphi, so
that your question isn't restricted to those who know Delphi...

However, if it's a case of formatting a floating point number, you just
call ToString on it and give it a format string - or include it in a
normal format string. For instance:

float f = 1.234567f;

string x = f.ToString ("#.##"); // x="1.23"

// x="My value is 1.234567"
x = string.Format ("My value is {0:G}", f);

Look up "number formatting" in the MSDN index for more information.
 
Back
Top