Thursday, 13 June 2013

C# - How to fix error Backing field for automatically implemented property '' must be fully assigned before control is returned to the caller. Consider calling the default constructor from a constructor initializer.

Backing field for automatically implemented property '' must be fully assigned before control is returned to the caller. Consider calling the default constructor from a constructor initializer. 

Watch online:


Replace

    public struct Users
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public bool IsSalary { get; set; }

        public Users(string fn, string ln, bool sal)
        {
            FirstName = fn;
            this.LastName = ln;
            this.IsSalary = sal;
        }
    }

With

    public struct Users
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public bool IsSalary { get; set; }

        public Users(string fn, string ln, bool sal)
            : this()
        {
            FirstName = fn;
            this.LastName = ln;
            this.IsSalary = sal;
        }
    }

No comments:

Post a Comment