C#枚举与string类型相互比较


public enum ChatTemplateFunctionType
{
  tt,
  aaaaa,
}

Enum.Parse(typeof(enum), string),来进行比较;

public void XXX(string strType)
{
  if (!string.IsNullOrEmpty(strType))
  {
    switch (Enum.Parse(typeof(ChatTemplateFunctionType), strType))
    {
      case ChatTemplateFunctionType.tt:
      break;
    }
  }
}

完毕!!!!!

C