Skip to main content

Posts

Showing posts from December 28, 2014

New in C#6

1. $ sign The purpose for it is to simplify string based indexing and that is all. its not some thing like current dynamic features of C# since it internally uses regular indexing functionality. to understand lets consider following example: var col = new Dictionary() { // using inside the intializer $first = "Hassan" }; //Assign value to member //the old way: col["first"] = "Hassan"; // the new way col.$first = "Hassan"; 2. Exception filters: Exception filters are already supported in VB compiler but now they are coming into C#. exception filters lets you specify a condition for a catch block. the catch block gets executed only if the condition is satisfied, this one is my favorite feature, so let's look at an example: Collapse | Copy Code try { throw new Exception("Me"); } catch (Exception ex) if (ex.Message == "You") { // this one will not execute. } catch (Exception ex) if (ex.Message == "Me") { // this one ...