NullReferenceException when trying to set class property

后端 未结 7 1689
醉酒成梦
醉酒成梦 2021-01-22 00:56

Basically I have 2 classes, \"Manifest\" and \"BrowserAction\", set out like this:

public class BrowserAction
{
    public string default_icon {get; set;}
    pu         


        
7条回答
  •  后悔当初
    2021-01-22 01:50

    browser_action has not been initialized. Add a parameterless constructor to your Manifest class like this:

    public class Manifest
    {
        public Manifest()
        {
               this.browser_action = new BrowswerAction;
        }
    
        public BrowserAction browser_action {get; set;}
    }
    

提交回复
热议问题