string and int are two complety different types. Basically, casting only
works on two compatible (derived) types. A string and an int are no where
near the same. They may look it, but 1 is not "1" by any means. So in order
to 'convert' something to something (in this case, string to int),
Convert.ToInt32 () must be invoked.
As far as i know, casting works best in the cases of inheritance and
polymorphism. I can explain your conversion problem more if you have
knowledge in those two areas.
Hope that helps,
Tim (new to C#, but proficient in C++).
"Frazer" <Ic***@hotmail. com> wrote in message
news:Oy******** ******@TK2MSFTN GP09.phx.gbl...
hi,
I am confused when to use (int) and when to use Convert.toint32 ..
eg here
string s= "1";
int j = (int) s; //this gives me an error and i have to use
convert.toint32 .
why is that so and how do i know when to use which.
thnx