【发布时间】:2016-09-21 07:18:26
【问题描述】:
这是我的代码:
public ActionResult Index()
{
var EmployeerId = SessionPersister.Email_ID;
//Convert.ToInt32(EmployeerId);
int.Parse(EmployeerId);
db.Job_Det.OrderByDescending(j => j.Job_ID).ToList().Where(x => x.Employeer_ID = EmployeerId);
return View();
}
我尝试了许多转换方法..但我未能将上述字符串转换为整数。
【问题讨论】:
-
为什么你知道它失败了?
-
如果
EmployeerId是string,那么需要先转换成int -
x => x.Employeer_ID = EmployeerId只有一个等号?此外,您的 int.parse 结果没有要存储的变量。 -
是的,var Employeerid 是字符串,需要将其转换为 int... 因为我尝试了许多转换方法但没有效果。
-
@JaffarHayat:它不会改变变量的类型,不——它不能。相反,这些方法返回一个新值。
标签: c# asp.net-mvc type-conversion