If you are regularly doing an operation on a common type, extension methods are a great way to create shorthand functions for this.

In this post I am sharing my string extension method to convert a string to Title Case (Pascal Case):

Imports System.Globalization
Imports System.Runtime.CompilerServices

Public Module StringExtensions
    ''' <summary>
    ''' This extension function converts a string to TitleCase.
    ''' </summary>
    ''' <param name="inputString">String to convert.</param>
    ''' <returns>Converted string.</returns>
    <Extension()>
    Public Function ToTitleCase(inputString As String) As String
        If (String.IsNullOrEmpty(inputString)) Then
            Return inputString
        End If

        Return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(inputString.ToLower)
    End Function

End Module

Join The Discussion