The following code throws an compile-time error like
Cannot convert type \'string\' to \'int\'
string name = Session[\"name1\"].ToString(); int i = (
Convert.ToInt32
return int.Parse(value, CultureInfo.CurrentCulture);
but (int) is type cast, so (int)"2" will not work since you cannot cast string to int. but you can parse it like Convert.ToInt32 do