FormatNumber in C#

F

fran

Hi!

I need to use a fucntion to format a number in c#, i have
tried to use the FormatNumber function of vb.net, but the
compiler doesn´t recognize it,

Is there any similar function in c#??

Thanks for all
 
J

Jon Skeet [C# MVP]

fran said:
I need to use a fucntion to format a number in c#, i have
tried to use the FormatNumber function of vb.net, but the
compiler doesn´t recognize it,

Is there any similar function in c#??

Either use String.Format, or int.ToString (assuming it's an int). For
example:

String hex = 23.ToString("x"); // hex is now "17", which is 23 in hex.
 
B

Brian W

try something like:

int x = 100;

string myString = x.ToString("0000");


HTH
Brian W



Hi!

I need to use a fucntion to format a number in c#, i have
tried to use the FormatNumber function of vb.net, but the
compiler doesn´t recognize it,

Is there any similar function in c#??

Thanks for all
 
A

ally

The following function call returns "7,226":

format-number(7226,"#,###")The following function call returns "3458.00":

format-number(3458, "#.00")"fran" <[email protected]>, iletide sunu yazdi

Hi!

I need to use a fucntion to format a number in c#, i have
tried to use the FormatNumber function of vb.net, but the
compiler doesn´t recognize it,

Is there any similar function in c#??

Thanks for all
 

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

Top