To convert string in title case is bit tedious and may require lot of code as there is no direct method available in C#.Net in String class. So, here I am sharing a method, which will be the extension method for String class and can be used to convert given string to title case. Here I am using CultureInfo from Globalization and ToTitleCase method of TextInfo class. public static class StringExtensions { public static string ConvertToTitleCase(this string input) { System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; return textInfo.ToTitleCase(input.ToLower()); } } Hope reusing this will save lot of your time :) ...
This blog is all about my technical learnings pertaining to LLM, OpenAI, Azure OpenAI, C#, Azure, Python, AI, ML, Visual Studio Code and many more.