ToSentence

public static string ToSentence(this string variableName)
{
    var builder = new StringBuilder();

    char[] chars = variableName.ToCharArray();

    foreach (char c in chars)
    {
        if (char.IsLetter(c) && char.IsUpper(c))
        {
            builder.Append(" ");
        }

        builder.Append(c);
    }

    variableName = builder.ToString().TrimStart();

    return variableName;
}
Example:
Create an extension method on a DataGrid to pretty print the column names.

public static void SetLabelsToSentences(
    this XamDataGrid xamDataGrid)
{
    foreach (
        Field field in xamDataGrid.FieldLayouts[0].Fields)
    {
        xamDataGrid.SetLabel(
            field.Name, field.Name.ToSentence());
    }
}

Description

Creates a sentence from a variable name.

Details

Double click on the code to select all.

 

;