.NET method to convert a string to sentence case

后端 未结 9 1741
一向
一向 2020-11-30 09:47

I\'m looking for a function to convert a string of text that is in UpperCase to SentenceCase. All the examples I can find turn the text into TitleCase.

<
9条回答
  •  心在旅途
    2020-11-30 10:17

    public string GetSentenceCase(string ReqdString) {
        string StrInSentCase = "";
        for (int j = 0; j < ReqdString.Length; j++) {
            if (j == 0) {
               StrInSentCase = ReqdString.ToString().Substring(j, 1).ToUpper();
            }
            else {
                StrInSentCase = StrInSentCase + ReqdString.ToString().Substring(j, 1).ToLower();
            }
        }
        return StrInSentCase.ToString();
    }
    

提交回复
热议问题