using System.Globalization;
using System.Diagnostics;
public static void Main()
string[] s = new string[]{"1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th"};
if (s.Any(i=> val.EndsWith(i))
&& val.Substring(0,val.Length-2).All(i=>char.IsDigit(i)) )
Console.WriteLine("it works");
public static void methodtest()
Stopwatch swInititation = Stopwatch.StartNew();
Test("amar work", false);
totalTime = totalTime + swInititation.ElapsedTicks;
Stopwatch sw = Stopwatch.StartNew();
Test("amar " + i + "work", false);
totalTime = totalTime + sw.ElapsedTicks;
Console.WriteLine(i + ": Time taken old :" + totalTime);
Stopwatch sw = Stopwatch.StartNew();
Test("amar " + i + "work", true);
totalTime = totalTime + sw.ElapsedTicks;
Console.WriteLine(i + ": Time taken new :" + totalTime);
static async void Test(string Input, bool newtrick, bool showInputOutput = false)
TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
string output = string.Empty;
output = ConvertStringToTitleCase(Input, null, textInfo);
output = ConvertStringToTitleCaseNewTrick(Input, null, textInfo);
Console.WriteLine(" input : " + Input + " output : " + output);
private static string ConvertStringToTitleCase(string input, string transactionId, TextInfo textInfo)
if (string.IsNullOrWhiteSpace(input))
string title = textInfo.ToTitleCase(input);
string[] arr = title.Split(' ');
for (int i = 0; i < arr.Length; i++)
if (arr[i].Any(a => char.IsDigit(a)))
arr[i] = arr[i].ToLower();
string result = string.Join(" ", arr);
private static string ConvertStringToTitleCaseNewTrick(string input, string transactionId, TextInfo textInfo)
if (string.IsNullOrWhiteSpace(input))
string title = textInfo.ToTitleCase(input);
bool isNumericFound = false;
string[] arr = title.Split(' ');
for (int i = 0; i < arr.Length; i++)
if (arr[i].Any(a => char.IsDigit(a)))
arr[i] = arr[i].ToLower();
string result = isNumericFound ? string.Join(" ", arr) : title;