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

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book