转换int类型TryParse的作用

//转换int类型,selectedValue指定的值
                int id;
                int.TryParse(this.ddlCountry.SelectedValue, out id);
                info.CountryId = id;

SelectedValue为指定的值

使用TryParse必须先定义ID

TryParse为尝试转换

成功的:
string s= "1";
int ret = 0;
int.TryParse(s,out ret);

失败的:
s = "";
ret = 0;
int.TryParse(s,out ret);  

原文地址:https://www.cnblogs.com/evan51/p/3866992.html