This is going to be the shortest post on this board, and one of the most embarrassing!
I ‘inherited’ a file full of string values that contained over 10,000 entries. Problem was, they were all lower case. I wasn’t about to sit there and manually capitalize the first letter of each word in the list so I thought, “Hey… just write a quick function in the program that does it for you. It should only take a few lines, right?” Well, not for me.
I started working on a function that read in each line, searched for the first character and capitalized it. But how would you account for some words that should not be capitalized like ‘de’ as in “Cul de Sac” or initials or abbreviations? The more I thought about it, the more complex the function got. I started worrying that I was missing something… Well, I was.
Like I said, it’s kind of embarrassing, but while Googling to try and make sure I covered all my bases, I came across this gem on the MSDN site:
myString = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase( myString );
I couldn't believe it. It takes care of all automatic capitalization of the first letter of a word or string of words... Ugh! Oh well, I hope at least it saves some developer an hour of headaches!
b750c2e8-f7bd-4621-a16c-67860e44ab92|2|4.5