Click here to Skip to main content
15,888,461 members
Home / Discussions / C#
   

C#

 
GeneralRe: Assigning Generic Type during runtime Pin
Mark Churchill7-Oct-08 18:55
Mark Churchill7-Oct-08 18:55 
QuestionDetecting RDP sesssion Pin
John Sposato7-Oct-08 9:18
John Sposato7-Oct-08 9:18 
AnswerRe: Detecting RDP sesssion Pin
leppie7-Oct-08 23:47
leppie7-Oct-08 23:47 
QuestionDataType Casting / Convert Pin
Cihan Topçu7-Oct-08 9:13
Cihan Topçu7-Oct-08 9:13 
AnswerRe: DataType Casting / Convert Pin
DaveyM697-Oct-08 9:39
professionalDaveyM697-Oct-08 9:39 
AnswerRe: DataType Casting / Convert Pin
Wendelius7-Oct-08 9:44
mentorWendelius7-Oct-08 9:44 
AnswerRe: DataType Casting / Convert Pin
Pedram Behroozi7-Oct-08 10:00
Pedram Behroozi7-Oct-08 10:00 
AnswerRe: DataType Casting / Convert Pin
Mark Churchill7-Oct-08 19:07
Mark Churchill7-Oct-08 19:07 
This is a tricky one. ExecuteScalar returns an object. This means that if it returns an int, it will be wrapped as a "boxed" int, similarily if its actually returning something like an unsigned int, you'll get a boxed unsigned int.

Boxed ints can be cast to an int. Unsigned ints can be cast to an int.
Boxed unsigned ints cannot be cast to an int.

int x = (int)5L; // works
int y = (int)(object)5; // works
int z = (int)(object)5L; // fails


Convert.ToInt32 works (and I had to look into this before so I'm only going on memory) because it uses the IConvertible interface. (It also does a null-check as well, and returns zero - which might be another reason your casting code could fail).


QuestionAbstract class and Interface related of same methods we are extednind in class...... [modified] Pin
Roney7-Oct-08 8:40
Roney7-Oct-08 8:40 
AnswerRe: Abstract class and Interface related of same methods we are extednind in class...... Pin
Wendelius7-Oct-08 8:48
mentorWendelius7-Oct-08 8:48 
GeneralRe: Abstract class and Interface related of same methods we are extednind in class...... Pin
Roney8-Oct-08 20:50
Roney8-Oct-08 20:50 
GeneralRe: Abstract class and Interface related of same methods we are extednind in class...... Pin
Wendelius9-Oct-08 6:18
mentorWendelius9-Oct-08 6:18 
GeneralRe: Abstract class and Interface related of same methods we are extednind in class...... Pin
Roney9-Oct-08 20:52
Roney9-Oct-08 20:52 
GeneralRe: Abstract class and Interface related of same methods we are extednind in class...... Pin
Wendelius10-Oct-08 6:36
mentorWendelius10-Oct-08 6:36 
QuestionC Code Parser Pin
Dromar7-Oct-08 8:11
Dromar7-Oct-08 8:11 
AnswerRe: C Code Parser Pin
Wendelius7-Oct-08 8:27
mentorWendelius7-Oct-08 8:27 
GeneralRe: C Code Parser Pin
Dromar7-Oct-08 8:33
Dromar7-Oct-08 8:33 
GeneralRe: C Code Parser Pin
Wendelius7-Oct-08 8:43
mentorWendelius7-Oct-08 8:43 
AnswerRe: C Code Parser Pin
Caio Kinzel Filho7-Oct-08 10:47
Caio Kinzel Filho7-Oct-08 10:47 
GeneralRe: C Code Parser Pin
Mark Churchill7-Oct-08 19:09
Mark Churchill7-Oct-08 19:09 
QuestionDefine Collection property problem Pin
sepel7-Oct-08 6:18
sepel7-Oct-08 6:18 
AnswerRe: Define Collection propertu problem Pin
Guffa7-Oct-08 6:28
Guffa7-Oct-08 6:28 
GeneralRe: Define Collection propertu problem [modified] Pin
sepel7-Oct-08 7:36
sepel7-Oct-08 7:36 
AnswerRe: Define Collection property problem Pin
Mark Churchill7-Oct-08 19:24
Mark Churchill7-Oct-08 19:24 
GeneralRe: Define Collection property problem Pin
sepel7-Oct-08 21:58
sepel7-Oct-08 21:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.