Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# capitalize first letter of each word

public static class Capitalize
{
  public static string Word(string input)
  {
    if (string.IsNullOrEmpty(input))
    {
      return string.Empty;
    }
    var a = input.ToCharArray();
    a[0] = char.ToUpper(a[0]);
    for (var i = 1; i < a.Length; i++)
    {
      a[i] = char.ToLower(a[i]);
    }
    return new string(a);
  }

  public static string Sentence(string input)
  {
    return string.Join(" ", input.Split(' ').Select(Word));
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #capitalize #letter #word
ADD COMMENT
Topic
Name
1+4 =