ToUpper and ToLower first char and first word

StewartBW 705 Reputation points


Going to convert the first letter of each word to upper and lower case, to upper is simple, but to lower?


And to convert the first word of string to upper and lower case, no methods in .net?


An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,521 questions
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,636 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Jiachen Li-MSFT 27,746 Reputation points Microsoft Vendor

    Hi @StewartBW ,

    You can write one yourself, referring to the function below.

        Function ConvertToFirstLetterLowerCase(input As String) As String
            If String.IsNullOrWhiteSpace(input) Then
                Return input
            End If
            Dim words As String() = input.Split(" "c)
            For i As Integer = 0 To words.Length - 1
                If words(i).Length > 0 Then
                    words(i) = Char.ToLower(words(i)(0)) & words(i).Substring(1)
                End If
            Return String.Join(" ", words)
        End Function

    Best Regards.

    Jiachen Li

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Karen Payne MVP 35,286 Reputation points

    The following extension method lower cases the first character to lower.

    public static class StringExtensions
        public static string? FirstCharToLowerCase(this string? sender)
            if (!string.IsNullOrEmpty(sender) && char.IsUpper(sender[0]))
                return sender.Length == 1 ? 
                    char.ToLower(sender[0]).ToString() : 
                    char.ToLower(sender[0]) + sender[1..];
            return sender;
    0 comments No comments