我有一個名爲「stateType」的枚舉。如何在IF循環中設置枚舉
enum stateType : int
{
Unknown = 0,
Active = 1,
Inactive = 2
}
在我的功能「連接()」顯示下面我只需要在 枚舉「活動」時,顯示的版本。
static private void connction()
{
string hostName = this_event.variableData[0].atr_value;
string policyGuid = this_event.variableData[1].atr_value;
string policyVersion = this_event.variableData[2].atr_value;
string formatVersion = this_event.variableData[3].atr_value;
string enabled = this_event.variableData[4].atr_value;
string Version = "0.0.0.0";
if (this_event.variableData.Length >= 6)
{
Version = this_event.variableData[5].atr_value;
}
}
我將如何做到這一點,我需要在
if loop(if (this_event.variableData.Length >= 6)&& condition)
我做了這樣
if (this_event.variableData.Length >= 6 && stateType.Active)
{
Version = this_event.variableData[5].atr_value;
}
我得到來設定條件錯誤操作「& &」不能應用於'bool'和'Spo.SPDlib.SPD.SPD_clientStateType'類型的操作數D:\ P \ leaf.cs
您需要分配狀態,然後才能訪問它。 – 2011-02-03 10:54:43
好吧,您沒有通過寫入stateType狀態來將任何內容分配給`state`,因此很快就會解釋錯誤。但是,我不太明白你想要做什麼... – 2011-02-03 10:55:28
對不起,我已編輯我的問題 – peter 2011-02-03 11:02:34