Friday, May 18, 2012

How to: String to Pascal case from C#

We can return a string to Pascal case using regular expression or using our own logic. Here are two scenarios for doing this.

Method 1: Regular expression

public static string ToPascalCase(string pascalCaseString)
Regex r = new Regex("(?<=[a-z])(?<x>[A-Z])|(?<=.)(?<x>[A-Z])(?=[a-z])");
return r.Replace(pascalCaseString, " ${x}");

Method 2: String parsing.

/// <summary>
/// Convert the string to Pascal case.
/// </summary>
/// <param name="str">the string to turn into Pascal case</param>
/// <returns>a string formatted as Pascal case</returns>
public static string FormatPascalCase(string str)
StringBuilder sb = new StringBuilder(str.Length);
if (string.IsNullOrEmpty(str))
throw new ArgumentException("A null or empty value cannot be converted", str);

if (str.Length < 2)
return str.ToUpper();
// Split the string into words.
string[] words = str.Split(new char[] { }, StringSplitOptions.RemoveEmptyEntries);
foreach (string word in words)
sb.Append(string.Format("{0}{1}", word.Substring(0, 1).ToUpper(), word.Substring(1)));
return sb.ToString();

Hope this helps.

Friday, May 11, 2012

Zurker invitations, Join Zurker (Sign up now!)

Looking for a Zurker invitation? You have come to the right place. If you are not familiar with Zurker.

It is about a social networking platform that turns users into owners, a solution to the never-ending menace of data-sharing and wealth accumulation by social networking giants.

Scores of people have discussed the possibilities of the advertisement-heavy social media platforms like Facebook and twitter and now these platforms are abuzz with a new online site, which promises the users to be owners.

A hundred-odd Indian techies and other members/owners are now creating waves with the new platform which claims, “At Zurker, we’ve taken things a bit further. You don’t just own your data, you own the network. Every Zurker user can very easily become a co-owner (future shareholder) of Zurker.”

Interestingly, within three months, 88,053 Indians are into ‘Zurking’ online while the US has just 12,000.


Refer friends, own this networking site

Invite your friends to Zurker! Not only will your experience be more enjoyable, but you will be rewarded in the form of vShares. Zurker vShares become more and more valuable as the number of people using Zurker increases. The more people you refer, the more vShares you own, the more valuable those vShares become, and the more fun using Zurker becomes for you. It's a win-win-win!

Click here for Invitation