String Case Modification

Posted on 2005-05-05
Last Modified: 2010-04-16
Can anyone tell me if this is the most effective way to accomplish this.  I need to take a line of text that is stored in a string.  I have to convert all of the text to lower case and the first letter of every string in that line to upper case.  I have gotten as far as converting the whole line to lower and then using split(' ') to separate the line into a string array.  Now I am trying to determine if there is any other way of converting the first letter in each string to upper and then putting the string array back together into a complete string again.  Any suggestions?????

Question by:gvector1
    LVL 96

    Expert Comment

    by:Bob Learned
    Here's the culture-aware way:

    public class String_Functions

     public static string ToTitleCase(string text)
       System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
       System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;
       return textInfo.ToTitleCase(text);

    LVL 96

    Accepted Solution


    input = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(input);


    Author Comment

    Thanks a MILLION!!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    In one of my recent projects, I was working with IP cameras, I need to take some pictures from the camera and do some processing on it. The first step, was to retrieve the image from camera into Image object. So that it can be displayed or …
    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now