M
M
Maxim K2022-02-14 22:11:45
C++ / C#
Maxim K, 2022-02-14 22:11:45

How can I find out the number of elements in a class (maybe I didn't describe it that way)?

Hello. It is necessary to store the X,Y coordinate. I made a class like this:

class posBoll
        {
            public int XposBollX;
            public int XposBollY;
            public posBoll(int X, int  Y)
            {
                this.XposBollX = X;
                this.XposBollY = Y;
            }
        }


I enter the data:
List<posBoll> posBoll = new List<posBoll>();
posBoll xy;
......
xy = new posBoll(i, j); posBoll.Add(xy);


I can get values:
textBox1.Text = posBoll[0].XposBollX.ToString() + " " + posBoll[0].XposBollY.ToString();
               textBox1.Text += " " + posBoll[1].XposBollX.ToString() + " " + posBoll[1].XposBollY.ToString();


The values ​​are stored, but now I know that there are 4 of them. But how to find out the number of all data ??? posBoll.count() - doesn't work (((. Maybe you should use the structure at all)

THANK YOU

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question