Friday, January 3, 2020

C# - How to convert first character of string to upper letter

The problem is little complicated, because access to string chars (through indexer) is only read-only.
One way is this:

row.Constellation = arr[2].Trim().ToLower();
char[] ch = row.Constellation.ToCharArray();
ch[0] = char.ToUpper( row.Constellation[0] );
row.Constellation = new string( ch );

No comments:

Post a Comment