using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
public static void Main()
string FirstName = "HANI";
string LastName = "SAAD";
Console.WriteLine("PascalToProper: " + PascalToProper(Test));
Console.WriteLine("UppercaseFirst (dalton): " + UppercaseFirst(Test));
Console.WriteLine("ToTitleCase: " + ToTitleCase(FirstName));
Console.WriteLine("PascalToProper: " + PascalToProper(Test));
public static string PascalToProper(string message)
message.Select(x => char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' ');
public static string UppercaseFirst(string str)
if (string.IsNullOrEmpty(str))
return char.ToUpper(str[0]) + str.Substring(1).ToLower() + " ";
public static string ToTitleCase(string message)
TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
message = message.ToLower();
return myTI.ToTitleCase(message ?? "");
public static string ToTitleCaseIgnoreOrdinals(string message)
if (string.IsNullOrWhiteSpace(message))
string[] split = message.Split(' ');
StringBuilder formatted = new StringBuilder();
foreach (var item in split)
if (!Regex.IsMatch(item, @"^\d+"))
formatted.Append(ToTitleCase(" " + item));
formatted.Append(" " + item);
return formatted.ToString().Trim();