You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Model/Extensions/StringHelper.cs

39 lines
1.0 KiB

6 years ago
namespace MediaBrowser.Model.Extensions
{
/// <summary>
/// Helper methods for manipulating strings.
6 years ago
/// </summary>
public static class StringHelper
{
/// <summary>
/// Returns the string with the first character as uppercase.
6 years ago
/// </summary>
/// <param name="str">The input string.</param>
/// <returns>The string with the first character as uppercase.</returns>
public static string FirstToUpper(string str)
6 years ago
{
if (string.IsNullOrEmpty(str))
6 years ago
{
return string.Empty;
6 years ago
}
if (char.IsUpper(str[0]))
{
return str;
}
6 years ago
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];
}
});
6 years ago
}
}
}