I
I
Ivan Baturin2020-05-16 00:08:14
C++ / C#
Ivan Baturin, 2020-05-16 00:08:14

Why doesn't an object reference point to an object instance?

This exception is thrown when trying to create an object of the Equipment class and add it to the List
5ebf042d482c3281011598.png
. What is the problem?
Equipment class:

public class Equipment
    {
        public int countRun { get; set; }
        public List<string> Boots { get; set; }
        public List<string> Armors { get; set; }
        public List<string> Gloves { get; set; }
        public List<string> Helms { get; set; }
        public List<string> Rings { get; set; }
        public List<string> Amuls { get; set; }
        public List<string> Formuls { get; set; }

        public Equipment()
        {
            this.countRun = 0;
            this.Boots = null;
            this.Armors = null;
            this.Gloves = null;
            this.Helms = null;
            this.Rings = null;
            this.Amuls = null;
            this.Formuls = null;
        }
    }


The Equips class (serves only for storing a few objects of type Equipment):
static class Equips
    {
        public static List<Equipment> Equip { get; set; }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-05-16
@MrLumus

You declared a variable Equipas a list, but you didn't create the list itself, where is it new?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question