In Java there is an ArrayList , and there myList.get(0) and myList.get(myList.size()-1) .
But in C # I can’t find it at all ( item32[] doesn’t work). What are the options?

I need to remember the coordinates of the first and possibly the last touch of the mouse.

Do I need a dynamic array to solve this problem? How can you solve it differently?

  • why do you need an array if you need to store only two positions of the mouse? VladD has already written about the rest. - rdorn
  • The first array index is the initial position, the last one is the last))) such a crutch could not figure out how else to save these coordinates. And now I can not). Thanks for the answers, now I will think how to take the coordinates of the touches. Well, or the mouse (like taking a touch, but you need to check on the device - with the mouse do not want. Or I took the wrong). How else can you save them? And I am only interested in Y - axis - Krem Soda
  • But just 2 variables, first and last, for example, why not please? - rdorn
  • In LibGdx, I had the following: if (Gdx.input.isTouched ()) myArrayList.add (Gdx.input.getY ()); and I do not even know what to put in these first and last - in any case, both of these values ​​were equal to the last getY () - Krem Soda
  • and the intermediate values ​​were then used somewhere? - rdorn

1 answer 1

In C #, you must use List<int> , arrays are usually not convenient enough.

The first element is list.First() , the last list.Last() .

Don't forget using System.Linq .


An added bonus compared to Java: you do not need a wrapper like an Integer on an int .


If you are interested in mouse coordinates, then you will need, of course, a List<Point> (or in what kind of data structure, the coordinates of the mouse come to you).