Possible Duplicates:
Capitalizing word in a string
Make first letter upper case
I have a string like this:
var a = "this is a string"; Is there a simple way I can make the first character change to uppercase?
This is a string
Possible Duplicates:
Capitalizing word in a string
Make first letter upper case
I have a string like this:
var a = "this is a string"; Is there a simple way I can make the first character change to uppercase?
This is a string
If you are not worried about the fact that a string is immutable, than you can return a new string instance.
var a = "this is a string"; a = string.Format("{0}{1}", char.ToUpper(a[0]), a.Remove(0, 1)); But, if you are going to end up needing to do more string manipulation on the same value, you may want to consider using a StringBuilder instead.
var a = "this is a string"; StringBuilder builder = new StringBuilder(a); builder.Replace(a[0], char.ToUpper(a[0]), 0, 1);