String Case Modification

Posted on 2005-05-05
Medium Priority
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
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 13937227
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

Bob Learned earned 2000 total points
ID: 13937257

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


Author Comment

ID: 13937720
Thanks a MILLION!!!

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

840 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