I have ArrayListone that contains a fixed type of objects. However, every time I need to extract an object for a specific index, I need to give it the type of my type specified by the user from the type of the object.
Is there a way in C # to declare ArrayListfixed types like Java and C ++, or is there any work to avoid type casting every time?
Edit:
I apologize, I forgot to mention that I need the data structure to be thread safe , which is Listnot. Otherwise, I would just use regular Array. But I want to save myself from the efforts of clearly blocking and unlocking when writing an array.
So I thought about using it ArrayList, synchronizing it, but this requires typing every time.
source
share