473,388 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

FormatNumber in C#


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
Nov 15 '05 #1
3 19429
fran <pn***@iespana.es> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2


try something like:

int x = 100;

string myString = x.ToString("0000");
HTH
Brian W
"fran" <pn***@iespana.es> wrote in message
news:0b****************************@phx.gbl...

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
Nov 15 '05 #3
The following function call returns "7,226":

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

format-number(3458, "#.00")"fran" <pn***@iespana.es>, iletide sunu yazdi
news:0b****************************@phx.gbl...

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
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: eddie wang | last post by:
The following code with formatnumber function returns me the following code. Why? Thanks. <td align="right"><Font class=content4><%=formatNumber(ars.Fields("SOLD_AMOUNT"),2)%></td> Microsoft...
6
by: J. Baute | last post by:
I'm doing some tests to see if the Session.LCID can be used to easily change a user-dependant locale for number & date/time formatting in ASP. As far as I get the theory this should work, but I'm...
3
by: Greg | last post by:
I have a function for totalling decimal values provided in textboxes that form a column on a webpage. This script should total the values in the textboxes, displaying the result in the final...
4
by: Lakrom | last post by:
Hi to all this is a Data Base in SQL Server 2000 in page cartola.asp Good previously it asks for the date format where I only want the month in a consultation SQL and the solution is this:...
1
by: galsaba | last post by:
1. I want to have the value 01 if the number is 1 waht would be the function? 2. i think i need to use the function formatnumber. Where can I find on the web the syntex of cstr( ,...
1
by: fran | last post by:
Hi! I'm trying to use the FormatNumber function that appear in vb in c#, but the complier does not recognize it, Is there any function similar in c# ? What is the import needed?
4
by: John Sutor | last post by:
I need some code that, on each keyup event, will take all of the numbers typed into the text box and format as they type to look like this 100 1,000 10,000 100,000 1,000,000 John S
2
by: ozkarlav | last post by:
I'm working on a proyect for a shopping cart, the problem is the coding is not taking the thousands in the sum for the grand total e.g.: Sub total: 4,175.50 G.S.T.: 250.53 P.S.T: ...
7
by: kirkgilbert | last post by:
I am trying to do an onchange event in a form using a text field. The form is tied to a record set that is part of a repeated region. One the first record when I edit the data it works perfectly. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.