贴两个方法:

1.转换字符串为枚举型:

枚举:

          public enum Subject
                {
                   None = 0,
                  Logon = 1,
                  Logoff = 2,
                  Ready = 3,
                }

可以这样进行转换:

Subject subject=(Subject)Enum.Parse(typeof(Subject),"Logon");

switch(subject)
   {
    case Subject.Logoff :
     DoLogoff();
     break;

    case Subject.Logon:
     DoLogon();
     break;   

...........................

2. //大写字符串的首个字符
  private string UpperFirstChar(string str)
  {
   if(str == "")
    return "";

   if(!Char.IsUpper(str,0))
   {
    str = str.Substring(0,1).ToUpper() + str.Substring(1);
   }
   
   return str;
  }

VB.Net支持这个方法StrConv("abcdefg", VbStrConv.ProperCase),同样可以大写首个字母,不知道C#中有没有?

原文地址:https://www.cnblogs.com/onekey/p/82988.html