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

FirstCharToUpper

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

Source

<Extension()>
  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

Example

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: 5247