標籤:style blog color 使用 io ar cti div
定義:
/// <summary> /// The js function type(the same as name). /// </summary> [Flags] public enum CallJSFunctionTypes { None = 0, ResetFixedBar = 1 << 1, ResetRequiredField = 1 << 2, SetValidateSuccessTextBoxStyle = 1 << 3, SetValidateFailTextBoxStyle = 1 << 4, ResizeSummary = 1 << 5 //,All = 1 << 5 - 1 }
使用:
//可以先給個初始值.CallJSFunctionTypes JSFunctions = CallJSFunctionTypes.None;//...//可以這樣賦值, 想包含什麼意義, 就用"與"疊加. JSFunctions = CallJSFunctionTypes.ResetFixedBar | CallJSFunctionTypes.ResetRequiredField | CallJSFunctionTypes.ResizeSummary;//...//判斷是否包含某個意義if ((JSFunctions & CallJSFunctionTypes.ResetFixedBar) == CallJSFunctionTypes.ResetFixedBar){ //Do something.}
原理:
Int32 是 4位元組32位二進位
None = 0,
即 0000 0000 0000 0000 0000 0000 0000 0000
ResetFixedBar = 1 << 1,
即 0000 0000 0000 0000 0000 0000 0000 0001 -> 0000 0000 0000 0000 0000 0000 0000 0010
ResetRequiredField = 1 << 2,
即 0000 0000 0000 0000 0000 0000 0000 0001 -> 0000 0000 0000 0000 0000 0000 0000 0100
SetValidateSuccessTextBoxStyle = 1 << 3,
即 0000 0000 0000 0000 0000 0000 0000 0001 -> 0000 0000 0000 0000 0000 0000 0000 1000
SetValidateFailTextBoxStyle = 1 << 4,
即 0000 0000 0000 0000 0000 0000 0000 0001 -> 0000 0000 0000 0000 0000 0000 0001 0000
ResizeSummary = 1 << 5,
即 0000 0000 0000 0000 0000 0000 0000 0001 -> 0000 0000 0000 0000 0000 0000 0010 0000
All = 1 << 5 - 1
即 0000 0000 0000 0000 0000 0000 0010 0000 -> 0000 0000 0000 0000 0000 0000 0001 1111
賦值的時候:
ResetFixedBar|SetValidateSuccessTextBoxStyle|ResizeSummary
即
0000 0000 0000 0000 0000 0000 0000 0010
0000 0000 0000 0000 0000 0000 0000 1000
0000 0000 0000 0000 0000 0000 0010 0000
____________________________________
0000 0000 0000 0000 0000 0000 0010 1010
判斷的時候:
判斷有沒有ResetFixedBar, 相"與"(&)
0000 0000 0000 0000 0000 0000 0010 1010
0000 0000 0000 0000 0000 0000 0000 0010
____________________________________
0000 0000 0000 0000 0000 0000 0000 0010 即ResetFixedBar, 即存在ResetFixedBar
判斷有沒有ResetRequiredField, 相"與"(&)
0000 0000 0000 0000 0000 0000 0010 1010
0000 0000 0000 0000 0000 0000 0000 0100
____________________________________
0000 0000 0000 0000 0000 0000 0000 0000 即不存在ResetFixedBar