首页 > 学院 > 开发设计 > 正文

var的使用

2019-11-14 13:28:48
字体:
来源:转载
供稿:网友

List<EnterPRise> epList = ViewBag.epList;

foreach (var item in epList){

  //todo ...

}

 

当 List<Enterprise> epList = ViewBag.epList; 变为 List<EnterpriseInfo> epList = ViewBag.epList; 时,

下面的foreach语句根本不用改变,会加快编码速度.也就是可以简单的理解为 var 是类型的变量(本质是类型推断).

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表