I'm trying to make the following:

Step one : Check if the values have been stored more then x time, if so delete them.
Step two : Check if current value has been used before
Step Three : If used return False (and write value to arraylist), else return true (dont' write the value to the arraylist).

I thought this would be best if I create an arrayList. But how do i go about this?

Use List (generic) instead of ArrayList.
Use the Contains method to check if an object is already in the list.


When you say you want to check if they have been "stored more than x times", do you mean in the arraylist? If you are only allowing values to be stored if they havent been used then this check is redundant (unless you plan to populate the arraylist with existing that may contain duplicates).
Also, at step 2, do you mean you want to check if the value exists in the array list already?
If you are only going to store a single datatype then i'd recommend the List over the ArrayList. The following use a List of integers. The FindAll method uses a predicate search to return a new list containing all the matches:

List<int> intList = new List<int>();

int value = 3; //value to search for

List<int> matches = intList.FindAll(delegate (int i) { return i == value; });

if (matches.Count > 0)
    //item already in list
    //item not in list
    //add item

*palms face* of course, if you just want to check if it is in the list then ddanbe is correct....Contains() is a much simpler method :)
Mine will allow you to retrieve all instances of the value and then alter/delete them as you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.