日期:2014-05-19  浏览次数:20864 次

这段代码啥意思?

                public   static   int   FirstCatalogId
                {
                        set
                        {
                                System.Web.HttpContext.Current.Session[ "_firstCatalogId "]   =   value;
                        }
                        get
                        {
                                if   (System.Web.HttpContext.Current.Session[ "_firstCatalogId "]   ==   null)
                                {
                                        return   0;
                                }
                                else
                                {
                                        return   (int)System.Web.HttpContext.Current.Session[ "_firstCatalogId "];
                                }
                        }


value   是啥??没定义啊~~~谢谢~~

------解决方案--------------------
这段代码是一个类的属性

Value是一个int值
------解决方案--------------------
不需要定义的,这是属性的标准写法

使用的时候

设置:
类名.FirstCatalogId=100;

获得:
int a=类名.FirstCatalogId;

------解决方案--------------------
属性的写法:
public int aa
{
get { return m_aa; }
set { aa= value ; }
}
如:Class c_BB = new c_BB;
c_BB.aa = 45;(这个45就是你所说的保留字value--接受的外界赋值),属性的一个用途就是为了隐藏私有成员(比如此处的m_aa)用的。