请高人帮我解释一下下面语句的语法:
if(!HttpContext.Current.IsDebuggingEnabled &&
HttpContext.Current.Application["TreeConfig" + treeId] != null)
      //Application["TreeConfig" + treeId]是什么意思? {
return (TreeConfigData)HttpContext.Current.Application["TreeConfig" + this.treeId];
}
treeId已经定义的变量
TreeConfigData是一个数据集

解决方案 »

  1.   

    获取对 HttpApplicationState 集合中的对象的访问。重载该属性以允许通过名称或数字索引访问对象。
      

  2.   

    HttpContext.Current.Application为当前 HTTP 请求获取 HttpApplicationState 对象。“[]”是访问索引的语法。类似于树组,只是也可以通过名称来访问。["TreeConfig" + this.treeId就是这个名称。
      

  3.   

    谢谢,等会分全给你.~~~
    那HttpContext.Current.Application["TreeConfig" + treeId] != null判断是否为空干什么啊?
    有什么用?
      

  4.   

    那HttpContext.Current.Application["TreeConfig" + treeId] != null判断是否为空干什么啊?
    有什么用?
    ---------------
    如果不判断
    return (TreeConfigData)HttpContext.Current.Application["TreeConfig" + this.treeId];这句话会爆掉的
      

  5.   

    楼上的说了。
    (TreeConfigData)HttpContext.Current.Application["TreeConfig" + this.treeId]将对HttpContext.Current.Application["TreeConfig" + treeId] 执行强制转换,如果HttpContext.Current.Application["TreeConfig" + treeId] 值为null,转换会出异常。建议楼主看看.net语法方面的书。