A ad Mar 28, 2005 #1 Hi, What is the difference between (string)dr["FieldName"] and dr["FieldName"].ToString();
H Helge Jensen Mar 28, 2005 #2 ad said: Hi, What is the difference between (string)dr["FieldName"] Click to expand... casts dr["FieldName"] to a string. dr["FieldName"].ToString(); Click to expand... Gives the string representation of dr["FieldName"] If dr["FieldName"] is not an instance of string, that's definatly not the same Try to think of it as class Bar: ToFoo { Foo ToFoo() { return ...; } } Bar bar = new Bar(); now what is the diff between: (Foo)bar; and bar.ToFoo();
ad said: Hi, What is the difference between (string)dr["FieldName"] Click to expand... casts dr["FieldName"] to a string. dr["FieldName"].ToString(); Click to expand... Gives the string representation of dr["FieldName"] If dr["FieldName"] is not an instance of string, that's definatly not the same Try to think of it as class Bar: ToFoo { Foo ToFoo() { return ...; } } Bar bar = new Bar(); now what is the diff between: (Foo)bar; and bar.ToFoo();