Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when class has list as property and list is null #3

Open
parfilko opened this issue Jun 6, 2019 · 0 comments
Open

error when class has list as property and list is null #3

parfilko opened this issue Jun 6, 2019 · 0 comments

Comments

@parfilko
Copy link

parfilko commented Jun 6, 2019

error when class has list as property and list is null.
here is example:

Declare classes:

    public class ZZZ
    {
        public string aaa { get; set; } = "zzz aaa";
        public string bbb { get; set; } = "zzz bbb";
    }
    public class YYY
    {
        public List<ZZZ> zzz;              //   field !!!
        public string aaa { get; set; } = "yyy aaa";
        public string bbb { get; set; } = "yyy bbb";
    }
    public class XXX
    {
        public List<ZZZ> zzz { set; get; }  //  property !!!
        public string aaa { get; set; } = "xxx aaa";
        public string bbb { get; set; } = "xxx bbb";
    }

code:

    var zzList = new List<ZZZ>() { new ZZZ(), new ZZZ(), new ZZZ() };           //  some list

    var yy = new List<YYY>() {
            new YYY() { zzz = zzList },
            new YYY() { zzz = zzList }
    };
            
    var xx = new List<XXX>() {
            new XXX() { zzz = zzList },
            new XXX() { zzz = zzList }
    };
            
    var lstYY = new BindingListView<YYY>(yy);   //  ok
    var lstXX = new BindingListView<XXX>(xx);   //  ok

    // recreate with zzz = null
    yy = new List<YYY>() {
            new YYY(),
            new YYY()
    };

    xx = new List<XXX>() {
            new XXX(),
            new XXX()
    };

    lstYY = new BindingListView<YYY>(yy);       //  ok
    lstXX = new BindingListView<XXX>(xx);       //  error

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant