C# 字符串首字母大写

        /// <summary>
        /// 首字母大写转换
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string ToUpperFirst(this string str)
        {
            if (string.IsNullOrEmpty(str)) return string.Empty;

            char[] arr = str.ToCharArray();
            char letter = arr[0];

            if (letter >= 97 && letter <= 122)
                letter = (char)(letter & ~0x20);

            arr[0] = letter;
            return new string(arr);
        }

本人亲测可用。。。

原文地址:https://www.cnblogs.com/FGang/p/15670567.html