Skip to main content

Here is a code snippet for transforming first letter to upper case in C# 

/// <summary>
/// Method returns string with replaced first letter to uppercase
/// </summary>
/// <param name="text">string text for replacing</param>
/// <returns>string replaced text wiht first letter to uppercase</returns>
public string UppercaseFirst(string text)
{
  // Check for empty string.
  if (string.IsNullOrEmpty(text))
  {
    return string.Empty;
  }
   
  // Return char and concat substring.
  return char.ToUpper(text[0]) + text.Substring(1);
}

- Advertisement -
- Advertisement -