difference between Convert.ToInt32 and (int)
- by balalakshmi
the following syntax throws an compile time error like
Cannot convert type 'string' to 'int'
string name=(Session["name1"].ToString());
int i = (int)name;
whereas the code below compiles and executes successfully
string name=(Session["name1"].ToString());
int i = Convert.ToInt32(name);
I would like to know
1) why the compile time error occurs in first code
2) what's the difference between the 2 code snippets