namespace MediaBrowser.Model.Extensions
{
    /// 
    /// Helper methods for manipulating strings.
    /// 
    public static class StringHelper
    {
        /// 
        /// Returns the string with the first character as uppercase.
        /// 
        /// The input string.
        /// The string with the first character as uppercase.
        public static string FirstToUpper(string str)
        {
            if (str.Length == 0)
            {
                return str;
            }
            if (char.IsUpper(str[0]))
            {
                return str;
            }
            return string.Create(
                str.Length,
                str,
                (chars, buf) =>
                {
                    chars[0] = char.ToUpperInvariant(buf[0]);
                    for (int i = 1; i < chars.Length; i++)
                    {
                        chars[i] = buf[i];
                    }
                });
        }
    }
}