Mohanapriya R Mohanapriya R
Updated date Jun 10, 2024
In this article, we will learn how to convert text from Title Case to a regular string using C#.

How to Convert Title Case to String in C#?

To convert text from Title Case to a regular string format in C#, we can utilize the TextInfo.ToTitleCase() method available in the System.Globalization namespace. This method converts the specified string to Title Case format. However, to convert it back to a standard string format, we need to manipulate the casing of each word individually.

using System;
using System.Globalization;

class Program
{
    static void Main(string[] args)
    {
        string titleCaseText = "The Quick Brown Fox Jumps Over The Lazy Dog";
        string[] words = titleCaseText.Split(' ');

        TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

        string regularString = "";

        foreach (string word in words)
        {
            regularString += textInfo.ToLower(word[0]) + word.Substring(1) + " ";
        }

        regularString = regularString.Trim();

        Console.WriteLine("Converted String:");
        Console.WriteLine(regularString);
    }
}

Output:

Converted String:
the quick brown fox jumps over the lazy dog

Comments (0)

There are no comments. Be the first to comment!!!