ExtensionMethod.NET Home of 846 C#, Visual Basic, F# and Javascript extension methods


Converts the first char of a string to an upper case letter.


  Public Function FirstCharToUpper(str As String) As String

    If String.IsNullOrEmpty(str) Then Return str

    Dim sb As New StringBuilder(str)

    sb.Chars(0) = sb.Chars(0).ToString.ToUpper

    Return sb.ToString

  End Function


Dim lStr = "this is a test"
Dim uStr = lStr.FirstCharToUpper()
'uStr = This is a test

Author: noxon

Submitted on: 7 mrt 2013

Language: VB

Type: System.String

Views: 4053