New Fresh deep-dives on cloud, AI, mobile & web now publish on blog.msdevbuild.com Read the latest → Install the app
Web

C# 6.0 New Feature

By   Friday, January 23, 2015 comments
reads
React:

C# 6.0 New Feature



How to get C# Updated Version?
Two ways we can update C# 6.0
Updated Visual Studio into VS 2014
Or
Installing Roslyn Package in VS 2013

$ Sign :

Its simplify String indexing

Example:

var value = new Dictionary() {
// using inside the initialize
$first = "Nikhil"
}

Assign value to member

C# 5.0
 C# 6.0
Value[first] =”Nikhile”
Value. $first = “Nikhil”

Exception Filters:

Exception filter already support in Vb.net now C#.net as well start to support .Exception filter is nothing but in catch block we can specify If Condition.
IF condition is fail inside catch block statement it won’t execute.

         C# 5.0
 C# 6.0
          try
            {       }
            catch (Exception ex)
            {       }

  Try  {
     throw new Exception("Null Error");
          }
catch (Exception ex) if (ex.Message == " IndexError")
            {
                // this one will not execute.
            }
            catch (Exception ex) if (ex.Message == " Null Error ")
            {
             // this one will execute
            }

await in Catch block and finally block :

Previous version C# not support await keyword in catchblock and finally block ,Now in c# 6.0 start supporting

         C# 5.0
 C# 6.0

            try
            {
                DoSomething();
            }
            catch (Exception)
            {
             //Its not Support here
                await LogService.LogAsync(ex);
            }

            try
            {
                DoSomething();
            }
            catch (Exception)
            {
               // New feature it will support
                await LogService.LogAsync(ex);
            }

Declaration Expression:

This feature allows you to declare local variable in the middle of an expression. It is as simple as that but really destroys a pain.

         C# 5.0
 C# 6.0
Int  Qty;
Int.TryParse(txtnumber.Text, out Qty)

Int.TryParse(txtnumber.Text, Int out Qty)

Auto Property Initialize:

In C# 6.0 added new feature called auto propertyinitialize like below

public class Person
{
// You can use this feature on both
//getter only and setter / getter only properties
public string FirstName { get; set; } = "Nikhil";
public string LastName { get; } = "Jagathesh";
}

Primary constructors:

A primary constructor allows us to define a constructor for a type and capture the constructor parameters to use in initialization expressions throughout the rest of the type definition. Here’s one 

simple example:

//this is primary constructor

public Class Money(string currency, decimal amount)
{
public string Currency { get; } = currency;
public decimal Amount { get; } = amount;
}

Dictionary Initialize:

         C# 5.0
 C# 6.0
Dictionary country = new Dictionary()
            {
                { "India", "TN" },
                { "United States", "Washington" },
                { "Some Country", "Some Capital " }
            };
Dictionary country = new Dictionary()
            {
                // Look at this!
                ["Afghanistan"] = "Kabul",
                ["Iran"] = "Tehran",
                ["India"] = "Delhi"
            };

Null-Conditional Operator

This is an exception that almost always indicates a bug because the developer didn’t perform sufficient null checking before invoking a member on a (null) object.

Look below new feature very interesting

         C# 5.0
 C# 6.0
public static string Truncate(string value, int length)
{
  string result = value;
//this pain work for us
  if (value != null) // Skip empty string check for elucidation
  {
    result = value.Substring(0, Math.Min(value.Length, length));
  }
  return result;
}
public static string Truncate(string value, int length)
{         
  return value?.Substring(0, Math.Min(value.Length, length));
}




SJ
Suthahar Jegatheesan

Cloud, AI & Mobile Solutions Architect · 18+ years across Azure, Google Cloud and Firebase, C#, Python, .NET MAUI and Flutter. Author of the Xamarin Q&A Book.

More in this series

No comments:

sponsored

What Colleagues Say

“Suthahar is one of the most thorough and knowledgeable cloud architects I’ve worked with. His depth on Azure and ability to make complex mobile solutions work cross-platform is remarkable. He always delivers beyond expectations.”

AT Arun T. Senior Engineering Manager · Direct Manager

“I’ve followed Suthahar’s MSDEVBUILD blog for years — practical, deep, always current. Working alongside him confirmed what I suspected: he’s as sharp in person as on paper, and a genuinely generous mentor and architect.”

RK Rajesh K. Lead Developer · Mindtree

Certifications & Recognition

AZ-300 · Azure Architect Technologies AZ-301 · Azure Architect Design AZ-104 · Azure Administrator Associate AI-100 · Designing Azure AI Solutions DP-900 · Azure Data Fundamentals MCPD · Windows Phone Certified SAFe® 4 Scrum Master

Technical Expertise

☁ Cloud Platforms Microsoft Azure — Expert · 18 yrs App Services · AKS · Functions · Cosmos DB · APIM · Entra ID AWS & Google Cloud — Advanced
πŸ€– AI & Automation Azure OpenAI / GenAI — Advanced · 5 yrs RAG Pipelines · Bot Framework · Cognitive Services · Vision & Speech AI · ML.NET
πŸ“± Mobile Architecture .NET MAUI & Xamarin — Expert · 12 yrs Flutter · Native iOS/Android · Offline-First · Secure Storage & Auth
πŸ”’ Identity & Security Microsoft Entra ID — Expert OAuth 2.0 · OIDC · Zero Trust · Conditional Access · RBAC · Key Vault

Speaking & Community

Microsoft User Group Malaysia Recurring speaker on Azure architecture, AI integration and .NET mobile development across Malaysia and APAC.
Global Azure Bootcamp — Chennai Presented “AI into Xamarin Mobile Apps” at GAB Chennai, part of the worldwide Global Azure community event.
AI & Azure OpenAI Community Events Workshops and live demos on RAG pipelines, AI agents and intelligent workflow automation since 2023.
Mobile & Cloud Workshops — Coimbatore Multi-day deep-dive sessions at GRG Computer Technology, KG Microsoft Innovation Center and RVS College of Arts and Science.
500+Blog Articles
50+Conference Talks
10K+Monthly Readers
30Public Repositories
3Continents Delivered
New home

MSDEVBUILD now publishes on blog.msdevbuild.com

Every new article lands there first — cloud and Azure, AI and GitHub Copilot, .NET MAUI and Flutter, web and Firebase. It installs as an app, opens like a native one and keeps working offline.

MSDEVBUILD Assistant Ask about Suthahar, Azure, AI or mentorship
Hi! I’m a simple FAQ bot for MSDEVBUILD. Tap a question below or type your own.