This demonstrates another overload of String.Substring() which only
takes one parameter - a start index. In this case, it returns the
sub-string from index 1 to the end of the string.
As well as the previous responses, you may wish to consider the
following if you're doing this a lot - it avoids creating an extra
string unnecessarily:
if (originalFirst==upperFirst)
{
return original;
}
return upperFirst + original.Substring(1);
}
Note that that will perform the upper casing in the current culture -
you could write another version which specified which culture to use
(and used it in the call to char.ToUpper).
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.