str( number, width, presicion) function

  • Thread starter Thread starter Andrus
  • Start date Start date
A

Andrus

How to implement function

string Str( float number, ushort width, ushort presicion)

should return string whose size if width characters, left padded by spaces
and having presicion characters after decimal point using current culture
decimal
separator.

Andrus
 
This recommends only to use Format() function.

Do you have any sample how to pass width and presicion to Format() function ?

Variable witdh and precision does not come natural for String Format,
but it is possible:

public static string Str(double number, ushort width, ushort precision)
{
return String.Format("{0," + width + ":f" + precision + "}", number);
}


Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top