array in asp.net c#

ASP.NET C# 6.0 Features that every ASP.NET Developer should know about it!

 ASP.NET C# 6.0 Features that every ASP.NET Developer should know about it.
        1. Auto-property initializes
        public int ID { get; set; }
        public bool Role { get; set; } = true;
        public string Name { get; set; } = string.Empty;
        public DateTime CreatedDate { get; set; } = DateTime.Now;

       2. Expression bodied members
                   public string Name => string.Format("{0} {1}", FirstName, LastName);

        3. Getter-only auto-properties
                   public DateTime BirthDate { get; }

        4. String interpolation
                   public string FullName => $"{FirstName} {LastName}";

        5.Null-conditional operators
        //Before
        var customer = new List<Customer>();
        var name = string.Empty;

        if(customer.FirstOrDefault() != null)
        {
            name = customer.First().Name;
        }

        //RIGHT NOW
        var customer = new List<Customer>();
        var name = customer.FirstOrDefault()?.Name;

    5. Index initializes

    //Before
    Dictionary<int, string> dictObj = new Dictionary<int, string>
{
    {1, "S1" },
    {2, "S2" },
    {3, "S3" }
};

    //After
    Dictionary<int, string> dictObj = new Dictionary<int, string>
{
    [1] = "S1",
    [2] = "S2",
    [3] = "S3"
};

Reference link


ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.