Convert To Camel case

c# Code : Convert to camel case

public static class Program
{
static void Main(string[] args)
{
Console.WriteLine(  ToCamelCase(“hi this is Cool”));
Console.ReadLine();
}

public static string ToCamelCase(this string input)
{
string[] words = input.Split(‘ ‘);
StringBuilder sb = new StringBuilder();
foreach (string s in words)
{
string firstLetter = s.Substring(0, 1);
string rest = s.Substring(1, s.Length – 1);
sb.Append(firstLetter.ToUpper() + rest);
sb.Append(” “);

}
return sb.ToString().Substring(0, sb.ToString().Length – 1);
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s