Ah I see, clear. Thank you.
>Because GetType forces to check the content of the cell. If you stop to the Item property, it is an object.
>
>If you check the definition of the Item property in the help file, you will find that it is declared as Object:
>
>
>Gets or sets the data stored in the column specified by index.
>
>[Visual Basic] Overloads Public Default Property Item(Integer) As Object
>[C#] public object this[int] {get; set;}
>>
>>Hello Eric,
>>
>>>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).
>>
>>
>>
>>If the Item property returns an Object DataType why then the expression
>>(MyTable.Rows[0]["age"].GetType()) returns System.Single. I would expect Object instead, or am I mixing things?
>>
>>Thank you.
>>
>>Zakaria al Azhar
>>
>>
>>
>>>
>>>>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.