Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why do I have to convert a cell from object to single?
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
00976293
Message ID:
00976320
Views:
10
The Item property of the Rows collection returns an Object datatype by default. You have to cast this value into the datatype you need (from Object to Single in your case).

>Hello All,
>
>I have a dataset with a table. I want to perform a calculation on the column age which is a single. So I thought simple, just do something like this :
>
> Single  age =(MyTable.Rows[0]["age"]);
>
>
>Doing this I get an error : cannot implicitly convert type object to float. I checked the type of MyTable.Rows[0]["age"].GetType() and gives System.Single.
>
>My question why do I have to convert it? The type is right? I don't understand, could someone shed some light on it?
>
>Thank you.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform