简体   繁体   中英

Creating a class field of type IList<>?

I'm trying to create a POCO object called Friend.cs. I can't seem to create inline properties for the IList.

public class User
    {
        public string ID { get; set; }
        public string Name { get; set; }
        public string Rating { get; set; }
        public string Photo { get; set; }
        public string Reputation { get; set; }
        public string Group { get; set; }
        public string GroupColor { get; set; }
        public string PostCount { get; set; }
        public string PostPerDay { get; set; }
        public string JoinDate { get; set; }
        public string Views { get; set; }
        public string LastActive { get; set; }
        public string Title { get; set; }
        public string Age { get; set; }
        public string Birthday { get; set; }
        public string Sex { get; set; }
        public string LinkedIn { get; set; }
        public string Facebook { get; set; }
        public string Twitter { get; set; }
        public IList<Friend> {get???
}

Thanks for the help!

You forget the name of the property:

public IList<Friend> Friends {get; set;}

should work.

Your missing the property name

ie

Public IList<Friend> Friends { get; set; }
public class User
{
    public IList<Friend> Friends
    {
        get { return _friends; }
        set { _friends = new List<Friend>(value); }
    }

    private List<Friend> _friends;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM