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

Thursday, April 12, 2012

Download: SQL Server 2008 e-book

SQL Server 2008 e-book for download.. This book is part conceptual, exploring the new features and abilities for this next generation enterprise database product; and it is part tangible, demonstrating features via C# code and improved T-SQL.

Download here.

SQL Server Builds and Hotfixes

I have found this wonderful site for list of all known KB articles, hotfixes and other builds of MS SQL Server 2012, 2008 R2, 2008, 2005, 2000 and 7.0 that have been released so far.

Please visit this URL for all the information.

Monday, April 09, 2012

SQL: Difference Between Union vs. Union All

UNION
The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.

UNION ALL
The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.

The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table.

A UNION statement effectively does a SELECT DISTINCT on the results set. If you know that all the records returned are unique from your union, use UNION ALL instead, it gives faster results.