I have a string of text (about 5-6 words mostly) that I need to convert.
Currently the text looks like:
THIS IS MY TEXT RIGHT NOW
I
There's a couple of ways to go about converting the first char of a string to upper case.
The first way is to create a method that simply caps the first char and appends the rest of the string using a substring:
public string UppercaseFirst(string s)
{
return char.ToUpper(s[0]) + s.Substring(1);
}
The second way (which is slightly faster) is to split the string into a char array and then re-build the string:
public string UppercaseFirst(string s)
{
char[] a = s.ToCharArray();
a[0] = char.ToUpper(a[0]);
return new string(a);
}