Difference between Single and First in C#

In the extension methods Single / SingleOrDefault and First / FirstOrDefault have semantic distinction. Though in many places these methods are being used without the semantic consideration, more often they return the expected results. This behavior makes this misuse more common. Both the Single and First methods have an accompanying helper method named as xxOrDefault … Continue reading Difference between Single and First in C#

VS 2013 Preview – New Features

VS 2013 preview is here. It has loads of new cool features. Mainly it comes with the .NET 4.5.1 If you are to develop for Windows 8.1 then you should install VS 2013 preview. This blog post describes some of the cool features in the VS 2013. Immediately after installing the VS 2013 Preview, I … Continue reading VS 2013 Preview – New Features

Installing SQL Server 2012 on Windows 8

Installing SQL Server 2012 on Windows 8 is a pain, because SQL Server 2012 needs .NET 3.5. The problem is activating .NET 3.5 in Windows 8 via Turn On/Off Windows features won't help because .NET 3.5 is considered as an on demand installation feature. Windows Update also fail to address the need. There are good … Continue reading Installing SQL Server 2012 on Windows 8

AES Cryptography

Contains the code for AES encryption and decryption in C#. 1: public byte [] EncryptText(string plainData) 2: { 3: RijndaelManaged rij = new RijndaelManaged(); 4: 5: rij.GenerateKey(); 6: _key = rij.Key; 7:  8: rij.GenerateIV(); 9: _intializationVector = rij.IV; 10:  11: ICryptoTransform encryptor = rij.CreateEncryptor(_key, _intializationVector); 12:  13: using (MemoryStream msEncrypt = new MemoryStream()) 14: { … Continue reading AES Cryptography

checked and unchecked keywords in C#

This post explains about checked and unchecked keywords in C#. In arithmetic calculations when constants are involved compiler detects the overflows in the data types. For example look at the following code. 1: // int range is from -2,147,483,648 to 2,147,483,647 2: int i = 2147483647 + 10; The above will generate a compile time … Continue reading checked and unchecked keywords in C#

Detecting the Windows Phone Theme Background Color

We often need to detect the WP background theme color to switch the color schemes of our apps. This is very useful when we utilize the application bar and have some metro icons in our app. In built WP apps have this feature and switch between different icons. For example when you use the Messaging … Continue reading Detecting the Windows Phone Theme Background Color