我有一个枚举的扩展方法
public static IEnumerable<T> GetFlags<T>(this T value) where T : struct
{
CheckIsEnum<T>(true);
foreach (T flag in Enum.GetValues(typeof(T)).Cast<T>())
{
if (value.IsFlagSet(flag))
yield return flag;
}
}
我试图得到这样的结果:
Zone_Status_ZoneConditionFlagEnum flags = (Zone_Status_ZoneConditionFlagEnum)flagsRaw;
List<Zone_Status_ZoneConditionFlagEnum> ZoneConditionFlags_List = (List<Zone_Status_ZoneConditionFlagEnum>)flags.GetFlags();
但我明白了
NX584(NX584Test)->Error parsing message: Cannot implicitly convert type [Digicom.NX584Engine.Messages.Zone_Status_ZoneConditionFlagEnum] to System.Collections.Generic.List`1[Digicom.NX584Engine.Messages.Zone_Status_ZoneConditionFlagEnum].