Enum的几个常用方法

//  从string 到Enum

public DownloadProxyUsage ProxyUsage
  {
   get
   {
    string proxyUsage =
     ConfigurationManager.AppSettings[@"downloadProxyUsage"];

    if ( string.IsNullOrEmpty( proxyUsage ) )
    {
     return DownloadProxyUsage.Default;
    }
    else
    {
     return (DownloadProxyUsage)Enum.Parse(
      typeof( DownloadProxyUsage ),
      proxyUsage,
      true );
    }
   }
  }

//从Enum到string
        public new string ToString
        {
            get { return Enum.GetName(typeof(eCompress), eCompress.RAR); }
        }

posted @   我想去长安  阅读(311)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示