c# - NullReferenceException was Unhandled (for a class) -


this question has answer here:

i've been trying fix class null problem little bit. don't understand it. class null reason. make loadcontent null too. additional information says: object reference not set instance of object.

characterinfo chara;//chara class null chara.loadcontent(content);// error pointing   //this behind chara.loadcontent(content); texture = content.load<texture2d>("art/blueanvil"); healthbar = content.load<texture2d>("art/healthbar"); 

started happening after add loadcontent constructor, class, , started using chara.loadcontent(content);

please me expand knowledge in c# can remember how fix this.

you need instantiate object:

characterinfo chara = new characterinfo(); 

at point, you're declaring variable, you're not assigning actual value it, hence exception.

if loadcontent static factory method creates characterinfo objects based on value of passed parameter, should be:

characterinfo chara = characterinfo.loadcontent(content); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -