C# 6.0 – Elvis operator and other improvements


Microsoft has released yet another version of .Net framework (4.6) and C# (6.0). In this post I am highlighting few improvements released as part of C# 6.0 which will largely benefit day to day development activities of a C# developer.

Elvis operator or formally called null conditional operator (?.) makes the null check simple. In a highly hierarchical object structure this operator reduces the length of code required to check for null and proceed further.

public class Sale
public Order orderItem { get; set; } = new Order();
public class Order
public int orderId { get; } = 101;

To read the value of orderId from main() class, null checks are required on objects of two of its hierarchical structure.

Sale sale = new Sale();

if(sale != null && sale.orderItem !=null && sale.orderItem.orderId > 0)
Console.WriteLine(string.Format("In older C#, value is {0}", sale.orderItem.orderId));

if (sale?.orderItem?.orderId >0)
Console.WriteLine($"In 6.0 C#, value is {sale.orderItem.orderId}");

Elvis operator makes this simple by evaluating the above expression left to right. The expression sale?.orderItem?.orderId >0 evaluates to orderItem if the left operand sale is non-null; otherwise, it evaluates to null.

In the above class definition, you will observe the way I have initialized the properties. I have directly initialized orderItem next to the property definition and it’s called auto-property initializer. Also you will notice orderItem has only get and no setter, this feature is called get-only auto property.

Also in the above code block you will notice, first I used string.Format to format the string and latter a special and simplified template to do the same. This is again a new feature in C# 6.0 called Interpolated Strings. An interpolated string expression creates a string by replacing the contained expressions with the ToString representations of the expressions’ results.

Bdotnet – Visual Studio 2013 Community Launch


This Saturday (14-December-2013) I was privileged to attend my 1st Bdotnet event in Microsoft office Bangalore. I had started exploring VS 2013 from the RT build and every time it gave me new stuffs to rejoice. So was I exited to hear more from experts on various new features, tips and tricks.

First session was by Tejasvi Kumar who made official community launch of Visual Studio 2013. He introduced few exiting features of VS 2013, including Visual Studio Online and CodeLenses. Just before this session, filler by Lohith was awesome. I would love to be part of such discussion. Many a times we try to discover new stuffs, advanced stuffs but start to forget basics. Lohith touched basics of web request response.

Later session was by Vic Parmar, who took us through new features introduced in VS 2013. One of the feature was Synchronized settings with which one can take his settings across devices. Those settings include, user preferences such as chosen color schema, text editor settings etc. I would expect much more from this sync settings such as synching of extensions and add-ons added. So that once you setup your environment, wherever you go and login to VS, sync will bring those settings to you and you will get homely feeling.

Next sessions were by Rajasekharan Vengalil and Karthikeyan Anbarasn on developing cloud based applications and Windows Azure applications. Since I had to rush for some other appointment, I could not attend rest of the sessions, but I am sure, I missed the session by Lohit on MONACO.

Overall the event was well organized. Thanks to the entire BDotnet team.

Windows 8 Keyboard Shortcuts


As Windows 8 and 8.1 are catching up, old Windows users are missing their favorite Start button. Also Windows 8 has introduced lot many new features to improve the usability and productivity. For example there is a charms to search, access settings etc. Instead of depending on mouse for calling all these functions, it would be good if we know the keyboard shortcuts. Here is the excel sheet which has most popular Windows shortcuts.

Download Windows 8 Shortcuts

Source: Yash’s Blog

Visual Studio Online


Wow!! This the word I exclaimed when I first saw Visual Studio Online. This is combination of collaboration, planning, version control tools and over cloud. Exciting??!!   Actually this is not something new, Microsoft has renamed their existing Team Foundation Service as Visual Studio One.

As soon as I installed Visual Studio 2013, it asked me to create http://___.visualstudio.com profile. That’s it!!! I am now ready with all above said combination of tools to start.


You can choose among TFS and Git as your version control system and this gets integrated with your Visual Studio IDE. So as you create the project, you can start collaborating with your team members. Also there are various out of box agile/scrum templates to manage your epic, stories and iterations. In addition to these, VSO (Visual Studio Online) has quality related tools integrated. You can do code reviews, build, test plans, test case execution etc.

Advanced VSO even provide lighter version of Visual Studio to edit code, automated builds, load tests, etc. With Visual Studio Online, Microsoft is offering broad range of tools and services that support the different kinds of development code named “Monaco” specifically designed for building and maintaining Windows Azure Websites.

Visual Studio 2012 – Paste XML as Classes

images (1)

Here we have a new version of Microsoft Visual Studio, Visual Studio 2012.

This new version is coming out at the time of diversification of computing technology and platform. So this new version is loaded with new capabilities for Windows 8, the web, SharePoint, mobile, and cloud development.

This new version has brought a lot of new and interesting features. Out of which today I was more exited with feature “Paste XML as Classes”.

Paste XML as Classes

Say you have a well formed XML file and need to deserialize it to a fully qualified .Net type objects. Building this manually is a very dull and monotonous job. Visual Studio 2012 has a new feature “Paste XML as Classes”.

Below is one sample well-formed XML.

Copy the XML content and open a new class file. From the menu select select Edit | Paste Special | Paste XML as Classes as shown below.

Visual Studio will automatically generate the code as shown below.


Get every new post delivered to your Inbox.

Join 181 other followers