导航

枚举1

Posted on 2007-08-07 16:33  woibobo  阅读(196)  评论(0)    收藏  举报
using System;
using System.Collections.Generic;
using System.Text;


namespace Test
{
    
/// <summary>
    
/// 对我可爱的枚举的测试
    
/// </summary>

    class Program
    
{
        
static void Main(string[] args)
        
{

            
//按位与  同1为1
            Console.WriteLine(2 & 3);//010 011  结果010  是2

            
//按位或  有1为1
            Console.WriteLine(2 | 4);//010 100  结果110  是6  与2+4相同 2的公约数有点特殊

            Console.WriteLine(
2 | 3);//010 011  结果011  是3  不是2的公约数

            Console.WriteLine(
2048 | 67108864);
            Console.WriteLine(
2048 + 67108864);

            Console.WriteLine(
"------------------------------");

            
//如果是单独的枚举
            
//则只有为本身时 值才是本身值
            
//否则为零
            Console.WriteLine(8 & 16);  //0
            Console.WriteLine(32 & 16); //0
            Console.WriteLine(16 & 16); //16

            Console.WriteLine(
"------------------------------");

            
//如果是联合枚举
            
//则只有里面有这个枚举时 值才是本身值
            
//否则为零
            Console.WriteLine((2+8& 16); //0
            Console.WriteLine((8 + 32& 16); //0
            Console.WriteLine((2048 | 67108864& 16); //0
            Console.WriteLine((2 + 16& 16); //16
            Console.WriteLine((32768 | 16& 16); //16

            Console.WriteLine(
"------------------------------");

            
//声明一个联合枚举
            UltraGridState aa = UltraGridState.CellFirst | UltraGridState.CellLast | UltraGridState.FirstRowInGrid;
            Console.WriteLine((
long)aa);

            
if (((long)aa & (long)UltraGridState.FirstRowInGrid)!=0)
            
{
                Console.WriteLine(
"包含"+UltraGridState.FirstRowInGrid.ToString());//是包含的
            }


            aa 
= UltraGridState.CellFirst | UltraGridState.CellMultiline;

            
if (((long)aa & (long)UltraGridState.FirstRowInGrid) != 0)
            
{
                Console.WriteLine(
"包含" + UltraGridState.FirstRowInGrid.ToString());
            }

            
else
            
{
                Console.WriteLine(
"NO2");//是不包含的
            }


        }

    }


    
/// <summary>
    
/// 一个可爱的枚举
    
/// </summary>

    public enum UltraGridState
    
{
        
// 摘要:
        
//     Active Cell not null
        Cell = 1,
        
//
        
// 摘要:
        
//     Active Cell is first cell
        CellFirst = 2,
        
//
        
// 摘要:
        
//     Active Cell is last cell
        CellLast = 4,
        
//
        
// 摘要:
        
//     Active Cell can be dropped down
        HasDropdown = 8,
        
//
        
// 摘要:
        
//     Active Cell is in edit state
        InEdit = 16,
        
//
        
// 摘要:
        
//     Active Cell has a check box
        IsCheckbox = 32,
        
//
        
// 摘要:
        
//     Active Cell is dropped down state
        IsDroppedDown = 64,
        
//
        
// 摘要:
        
//     Active Row is not null
        Row = 128,
        
//
        
// 摘要:
        
//     Active Row is a child row
        RowChild = 256,
        
//
        
// 摘要:
        
//     Active Row is expandable
        RowExpandable = 512,
        
//
        
// 摘要:
        
//     Active Row is expanded
        RowExpanded = 1024,
        
//
        
// 摘要:
        
//     Active Row is the first Row
        RowFirst = 2048,
        
//
        
// 摘要:
        
//     Active Row is the first child (in its parent row)
        RowFirstChild = 4096,
        
//
        
// 摘要:
        
//     Active Row is the last Row
        RowLast = 8192,
        
//
        
// 摘要:
        
//     Active Row is the last child (in its parent row)
        RowLastChild = 16384,
        
//
        
// 摘要:
        
//     A GroupByRow is the active row.
        GroupByRow = 32768,
        
//
        
// 摘要:
        
//     If the current row is dirty.
        RowDirty = 65536,
        
//
        
// 摘要:
        
//     If the swap drop down is dropped down.
        SwapDroppedDown = 131072,
        
//
        
// 摘要:
        
//     If the filter drop down is dropped down.
        FilterDroppedDown = 262144,
        
//
        
// 摘要:
        
//     Active row is the fist row in the grid. This differs from RowFirst in that
        
//     RowFirst only takes into account sibling bands while FirstRowInGrid cosiders
        
//     the whole grid (all the bands).
        FirstRowInGrid = 524288,
        
//
        
// 摘要:
        
//     Active row is the last row in the grid. This differs from Rowlast in that
        
//     RowLast only takes into account sibling bands while LastRowInGrid cosiders
        
//     the whole grid (all the bands).
        LastRowInGrid = 1048576,
        
//
        
// 摘要:
        
//     Active row is a filter row.
        FilterRow = 2097152,
        
//
        
// 摘要:
        
//     Active row is an add-row.
        AddRow = 4194304,
        
//
        
// 摘要:
        
//     A state that indicates whether multi-cell copy operation can be performed.
        CanCopy = 8388608,
        
//
        
// 摘要:
        
//     A state that indicates whether multi-cell cut operation can be performed.
        CanCut = 16777216,
        
//
        
// 摘要:
        
//     A state that indicates whether multi-cell delete (deleting the contents of
        
//     the cells) operation can be performed.
        CanDeleteCells = 33554432,
        
//
        
// 摘要:
        
//     A state that indicates whether multi-cell paste operation can be performed.
        CanPaste = 67108864,
        
//
        
// 摘要:
        
//     A state that indicates whether multi-cell undo operation can be performed.
        CanUndo = 134217728,
        
//
        
// 摘要:
        
//     A state that indicates whether multi-cell redo operation can be performed.
        CanRedo = 268435456,
        
//
        
// 摘要:
        
//     A state that indicates whether the current cell in edit mode is a multi-line
        
//     cell.
        CellMultiline = 536870912,
    }

}