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 Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

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! Reviewed by Anil Singh on 5:10 AM Rating: (5)
www.code-sample.com/. Powered by Blogger.
^