Skip to main content


Showing posts from June, 2012

String.ToTitleCase() extension method to convert String to Title Case or Pascal Case

As you most of you already aware, there are ToLower() and ToUp­per() meth­ods available for String class in C#, but there is no method to con­vert a string to ‘Title Case’. We can implement this conversion with the help of Tex­tInfo class which has a ToTi­tle­Case method, but you can’t create a new instance of the Tex­tInfo type as there is no pub­lic con­struc­tor available. Instead you will need to first cre­ate a new CultureInfo object. To create a new CultureInfo object you can either use hard-coded culture or you can  use the cur­rent cul­ture of the exe­cut­ing thread as:
var cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
That way, if you don’t care about the cul­ture info you’re using, you will just default to what­ever cul­ture info your cur­rent thread is using, much cleaner than the alternative!
Here I'm writing extension method of String  namedToTitleCase, in class StringExtension, I have created three extension method, one with current culture info…

SQL SERVER – Database diagram support objects cannot be installed because this database does not have a valid owner

Add/Create ASP.NET Membership tables/view/sp with aspnet_regsql