How to make a first letter capital in C#

后端 未结 12 1207
攒了一身酷
攒了一身酷 2020-12-05 23:52

How can the first letter in a text be set to capital?

Example:

it is a text.  = It is a text.
12条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 00:14

    Try this code snippet:

    char nm[] = "this is a test";
    
    if(char.IsLower(nm[0]))  nm[0] = char.ToUpper(nm[0]);
    
    //print result: This is a test
    

提交回复
热议问题