"The modifier 'readonly' is not valid for this item"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shamira
    New Member
    • Dec 2012
    • 1

    "The modifier 'readonly' is not valid for this item"

    I need help with this error :"The modifier 'readonly' is not valid for this item"

    I am writing this code in projrct type class Library
    Here is the code:
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    
    namespace BE
    {
        public enum STATUSACCOUNT { Bounded, Active, OnProbation };
        public class Account
        {
            public int AccountNumber { get; set; }
            public int AccountBranchNumber { get; set; }
            public readonly DateTime DateOpeingAccount { get; set; } //error
            public STATUSACCOUNT StatusAccount { get; set; }
            public string Password { get; set; }
            public int Balance { get; set; }
            public int CreditFacility { get; set; }
            public DateTime CreditFacilityExpiration { get; set; }
            public string TypeAccount { get; set; }
        }
    }
    Thank you very much.
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    I would think you're getting that error because you have a getter & setter but have marked it as read only, which just cannot work. Try changing it to this:

    Code:
     
    public DateTime DateOpeingAccount { get; private set; }

    Comment

    Working...