Uppercase first in VB.Net

To capitalize only the first character of a string you can create an extension, like this:

Public Module MyModule

    Public Function UppercaseFirst(my_string As String) As String

        If String.IsNullOrWhiteSpace(my_string ) OrElse my_string .Length < 2 Then
            Return my_string 
        End If

        Return my_string .Substring(0, 1).ToUpper() & my_string .Substring(1)

    End Function

End Module

Leave a Comment

Your email address will not be published. Required fields are marked *