public static int ParseAttribute(string attribute)
        {
            if (string.IsNullOrEmpty(attribute)) return (int)blogAttribute.None;
            blogAttribute b = blogAttribute.None;   //这个是事例化吗? 能解析下吗
            attribute = string.Concat(",", attribute, ",");
            if (attribute.IndexOf(string.Concat(",", (int)blogAttribute.Hot, ",")) != -1)
                b |= blogAttribute.Hot;         //这句是什么意思了   |=  什么符号 。
            if (attribute.IndexOf(string.Concat(",", (int)blogAttribute.Commend, ",")) != -1)
                b |= blogAttribute.Commend;
            if (attribute.IndexOf(string.Concat(",", (int)blogAttribute.HeadLine, ",")) != -1)
                b |= blogAttribute.HeadLine;
            if (attribute.IndexOf(string.Concat(",", (int)blogAttribute.Top, ",")) != -1)
                b |= blogAttribute.Top;
            return (int)b;
        }高手解析下?谢谢落。

解决方案 »

  1.   

    blogAttribute.值像None,Hot,Top 都是blogAttribute里面定义的
      

  2.   

     public enum blogAttribute
        {
            /// <summary>
            /// 空
            /// </summary>
            None = 0x0,
            /// <summary>
            /// 推荐
            /// </summary>
            Commend = 0x1,        /// <summary>
            /// 热点
            /// </summary>
            Hot = 0x2,        /// <summary>
            /// 置顶
            /// </summary>
            Top = 0x4,        /// <summary>
            /// 头条
            /// </summary>
            HeadLine = 0x8
        }blogAttribute  我知道是枚举 
     blogAttribute b = blogAttribute.None; //能解析吗
    if (attribute.IndexOf(string.Concat(",", (int)blogAttribute.Hot, ",")) != -1)
      b |= blogAttribute.Hot; //这句是什么意思了 |= 什么符号 。
      

  3.   

    总于搜索到 blogAttribute b = blogAttribute.None; 这个是知道什么意思了 哈
     3.2.1 有一个0值成员  如果枚举类型中的某个成员被赋予0值(不要求是第一个成员),那么枚举变量所储存的值就是该成员的值。假定Alignment的成员被赋值如下://Code #06
    enum Alignment
    {
      Left = 1,
      Center = 0,
      Right = 2
    }  那么,下面这句  Alignment a = new Alignment();  将等效于  Alignment a = Alignment.Center;