Best way to convert Pascal Case to a sentence

后端 未结 16 1940
天命终不由人
天命终不由人 2020-12-08 13:00

What is the best way to convert from Pascal Case (upper Camel Case) to a sentence.

For example starting with

\"AwaitingFeedback\"

a

16条回答
  •  爱一瞬间的悲伤
    2020-12-08 13:27

    Mostly already answered here

    Small chage to the accepted answer, to convert the second and subsequent Capitalised letters to lower case, so change

    if (char.IsUpper(text[i]))                
        newText.Append(' ');            
    newText.Append(text[i]);
    

    to

    if (char.IsUpper(text[i]))                
    {
        newText.Append(' ');            
        newText.Append(char.ToLower(text[i]));
    }
    else
       newText.Append(text[i]);
    

提交回复
热议问题