String.ToTitleCase Bug?

Jan 13, 2011 at 4:21 PM

It appears that String.ToTitleCase() does not work.  Here's an example of what I'm trying to do:

String s = "this is a test";

s = s.ToTitleCase();

Feb 22, 2011 at 4:10 PM

Use this variant

public static string ToTitleCase(this string value)
{
return IfEmptyOrWhiteSpace(value.ToLower(), CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(value));
}

Developer
Feb 28, 2011 at 2:47 AM

Hi,

Thank you for posting the issue, and apologizes for my late reply.

I've looked into this bug, and indeed it is wrong to use IfEmptyOrWhiteSpace in this instant.

as IfEmptyOrWhiteSpace return the "default" value if it is empty. Therefor, what this method were doing was returning the "ToTitleCase" only if the value pass in is empty...

We do apologizes for not testing this prior releasing it.

This method has now been corrected, and a Unit testing has been put in place.

regards,

about.me/MichaelTran