Santosh Kumar Adidawarpu
What is a primary constructor C# 6.0?
By Santosh Kumar Adidawarpu in .NET on May 08 2016
  • Santosh Kumar Adidawarpu
    May, 2016 8

    Primary constructor is introduced in C# 6.0.It allows you to assign a value to an auto-property at declaration time only, just as with a field. Without primary constructor:public class Student {public int Id{ get; private set; }public Name { get; private set; }public Student(int id, string name){Id = id;Name = name;} }With primary constructor:public class Student {public Student(int id, string name){public int Id{ get; } = id;public Name { get;} = name;} }

    • 1


Most Popular Job Functions


MOST LIKED QUESTIONS