K-MUG User Group Meeting On 20th December – Kochi

Standard
K-MUG Logo

K-MUG Logo

Kerala Microsoft User Group (K-MUG) is conducting monthly UG meeting on 20th December 2014, Kochi

Venue:
Startup Village, Kinfra Hi-Tech Park, Kalamassery, Kochi, Kerala.

Agenda

  • 02:00 – 02:10 Community updates
  • 02:10 – 02:50 C# 6.0 – New Features by Anuraj P
  • 02:50 – 03:30 Object/Relational Impedance Mismatch by Aravindan M P
  • 03:30 – 03:40 Tea Break & Networking (10 min)
  • 03:40 – 04:20 Microsoft and Open Source by Praveen Nair
  • 04:20 – 05:00 Azure Service Bus by Shiju Varghese

You can find more details on K-MUG event page, you can register here.

New C# 6.0 features

Standard

As part of the Connect(); event, Microsoft introduced VS2015 Preview, which includes C# 6.0 with few more features. (These features are not included in my earlier post What is new in C# 6.0, as I already mentioned these features introduced by Microsoft in the Connect(); event few days back.)

  • nameof operator – nameof operator allows developers to use program elements as text. In MVVM project, you are using property notifications, it is recommended to use strongly typed property notifications, instead of string. Because you are hard coding the property name, if you rename the property, you need to change the string manually. The nameof operator helps you to use the property as the parameter.
    public string FirstName
    {
        get { return _firstName; }
        set
        {
            if (_firstName != value)
            {
                _firstName = value;
                OnPropertyChanged(nameof(FirstName));
            }
        }
    }
    

    Runtime will replace the property with the property name while generating the IL code.

    IL code generated for nameof operator

    IL code generated for nameof operator

  • null conditional dot operator – as the name indicates it for null checking. This helps you to make null checking fade into the background.
    static void PrintBook(Book book)
    {
        var name = book.Name;
        var price = book.Price;
        Console.WriteLine("Name :{0} - Price {1}", name, price);
    }
    

    I have a function like this, which will print the name and price of the book. Please note I am not doing any null check, if the book instance is null, it will throw exception. The null conditional dot operator helps to avoid this validation and processing. If you are invoking a property of null object instance, it will return null for that property as well, it won’t throw null reference exception.

    static void PrintBook(Book book)
    {
        var name = book?.Name;
        var price = book?.Price;
        Console.WriteLine("Name :{0} - Price {1}", name, price);
    }
    

    In case of value types, Visual Studio will treat the type of the variable as nullable, if you use null conditional dot operator.

    null conditional dot operator - with value types

    null conditional dot operator – with value types

  • string interpolation – Another cool feature, which will help you to manage string formatting easy. In the current framework, you need use string.Format function, it little complex, you need to put numeric place holders ({n}) and based on the number you need to set the variables. String Interpolation will help developers to use actual variables as placeholders.
    var message = string.Format("Book Name :{0} Price :{1}", name, price);
    

    Can be re-write like this.

    var message = "Book Name :\{name} Price :\{price}";
    

    It supports IntelliSense for the variable names, also variables can be identified with different color.

    String Interpolation - IntelliSense

    String Interpolation – IntelliSense

You can download VS 2015 Preview from here

Happy Coding :)

K-MUG Usergroup Meeting on 29rd November Kochi

Standard
K-MUG Logo

K-MUG Logo

Kerala Microsoft User Group (K-MUG) is conducting monthly UG meeting on 29th November 2014, Kochi

Agenda

  • 09:30 – 09:40 Community updates
  • 09:40 – 10:20 Continuous Integration & Build automation using Jenkins by Fazil VA
  • 10:20 – 11:00 Source code automation using T4 Template by Sunij K
  • 11:00 – 11:10 Tea Break & Networking (10 min)
  • 11:10 – 11:40 Language Manager by Libin Thomas
  • 11.40 – 12:30 Introduction to ASP.Net vNext by Anuraj
K MUG UG Meet November

K MUG UG Meet November

Thanks to @Ninethsense for the design.

You can find more details in K-MUG Event Page and you can register here