Re: Why "Specified cast is not valid" error?
From: Jack MacRank (jack_at_macrank.com)
Date: 11/22/04
- Next message: jijo kuruvila: "update a row in datagrid"
- Previous message: Peter Rilling: "Re: Generic HashTable Question"
- In reply to: Stefan Simek: "Re: Why "Specified cast is not valid" error?"
- Next in thread: Jon Skeet [C# MVP]: "Re: Why "Specified cast is not valid" error?"
- Reply: Jon Skeet [C# MVP]: "Re: Why "Specified cast is not valid" error?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 22 Nov 2004 17:21:01 GMT
Stefan,
I set a breakpoint and looked at the GetType() of "retval" after the query
executed. I was surprised to see it was of Int64 type. I didn't know
C#/.NET automatically converted an object variable to another type...I
thought it would just be a generic object type and then I could cast it to
whatever I wanted it to.
I'm still a little confused why I can't cast an Int64 to String but I will
take your advice and use .ToString() and Convert.ToInt32() when I want a
string or integer.
Thanks to everyone who responded to my question!
- Next message: jijo kuruvila: "update a row in datagrid"
- Previous message: Peter Rilling: "Re: Generic HashTable Question"
- In reply to: Stefan Simek: "Re: Why "Specified cast is not valid" error?"
- Next in thread: Jon Skeet [C# MVP]: "Re: Why "Specified cast is not valid" error?"
- Reply: Jon Skeet [C# MVP]: "Re: Why "Specified cast is not valid" error?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|