473,657 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert class

why there isn't a Convert.ToFloat () method in the Convert class?
Sometimes I can't work with a float field because there isn't this method
and I need it to, for example, convert the input in a textBox to a float
field.

Thank you
Nov 16 '05 #1
2 22205
Alberto,

You will have to use the ToSingle method on the Convert class. This is
the name for a float in the BCL. Float is an alias provided by C#.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Alberto" <al*****@nospam .com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
why there isn't a Convert.ToFloat () method in the Convert class?
Sometimes I can't work with a float field because there isn't this method
and I need it to, for example, convert the input in a textBox to a float
field.

Thank you

Nov 16 '05 #2
Alberto <al*****@nospam .com> wrote:
why there isn't a Convert.ToFloat () method in the Convert class?
Sometimes I can't work with a float field because there isn't this method
and I need it to, for example, convert the input in a textBox to a float
field.


Because Float isn't the name of the type in question - Single is.
There's a Convert.ToSingl e() method, just like there's
Convert.ToInt32 () instead of Convert.ToInt() .

The shorthand of "float" for System.Single is a C# notion, rather than
a .NET one.

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

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

Similar topics

1
2148
by: vipin | last post by:
My C# console application takes 5 parameters two of which are supposed to be inherently integers So I do COnvert.ToInt32(args) There is no problem with the console application when I run it at the command prompt But the above statement raises an exception when I use CreateProcess(NULL,CommandLin ....) from a C++ code I have the c# code compiled with /unsafe option
14
7319
by: Mick | last post by:
I wrote a C# program that interfaces with a data vendor over the web using an API they supplied and their examples in C#. Now I have another data vendor's API and example that I want to add to my C# program. But this new API is written in Java. They gave me an example source code that uses their API but the actual API looks like it is stored in a few .jar files. I unzipped those .jar files into many .class files. I think these .class...
3
10269
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function and there you have it. So I enquired and found the Convert class with it's promising ToInt32 method, great... but it doesn't work. The thing keeps throwing Format Exceptions all over the place. What is the "C#" way to do this??? code int wmin,...
2
1191
by: Makarand | last post by:
Hi Can anybody tell me how to use TypeConvertor class? Thing is i want to do dynamic(during runtime) type casting in my code. Thnanx Makarand
2
2144
by: swartzbill2000 | last post by:
I want to PostMessage from a class instance to its containing form. I want the WPARAM to point to the class instance. I am using the declaration of PostMessage from www.pinvoke.net. WPARAM is an IntPtr. VB2005 won't let me do this: CType(Me, IntPtr) How can I pass Me as the WPARAM arg? Bill
4
9165
by: Hyun-jik Bae | last post by:
Is that not allowed to assume generic type numeric type? As far as I've tried, I got an error with the following code: public class AAA<T> { public int Foo(T a) { return a; // error: Cannot implicitly convert type 'T' to 'int' } }
1
5484
by: quantass | last post by:
Im using C#, ASP.NET v1.1. My class contains intrinsic types, ArrayList, and XmlDocument types. Some variables have the value NULL. After usng XmlSerializer and the information on: http://www.phdcc.com/xml2json.htm I'm having issue fully converitng my class object to a javascript readable string. The XmlSerializer appears to ignore all variables containing NULL and so the final JSON output is incomplete. Also I have a DateTime...
3
1986
by: rengaraj | last post by:
Dear Friends, Any software available for converting .class file to .java file. ?? If any please suggest. Advance Thanks, Rengaraj.R
1
7105
by: ramanujam kv | last post by:
I have two C# classes (Interop & Assembly)which is shown below public class CTest { public CTest() { } public void SimpleFunction()
0
8413
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.