Answer the question
In order to leave comments, you need to log in
How to create a class that initializes an indefinite number of array elements in its field?
There is a class, there is a field which is an array.
What is the best way to create it?
I'm assuming that we pass values to the constructor and initialize the array in the constructor ?
Or is it not possible, and should we use List ?
Added
------
And how to use get set ?
Answer the question
In order to leave comments, you need to log in
something like:
class test
{
public int[] arr;
public test(int N)
{
arr = new int[N];
}
}
look at the sources of the List<> class and the IList<> interface
and find out how the
spoiler sheet works - it works with an array
Hello.
Something tells me that you need to implement an iterator. Read
here .
If not, please describe the problem in more detail. Then get a more accurate solution
Read about get and set
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question