Reputation: 25
I am strugling with the int[Array]
since yesterday.
I have the following code:
public int[] Numbers
{
get
{
return class.intNumbers();
}
set
{
int[] Number = class.intNumbers();
Number[Number.Length + 1] = value;
writer.NumberValue("Name", "Id", "Here goes the Array");
}
}
What I want the code to do is to take the array from other class and on the next index to put my value.(Fails at Number[Number + 1] = value;
) The get method is succesfully finished, all I have to do now is "set". Do you have any ideas?
P.S I only want to use array and not arraylist :)
Upvotes: 1
Views: 82
Reputation: 6965
You can use ArrayResizer, although I don't know why you do not want to use List here.
int[] arr = { 1, 2, 3 };
Array.Resize(ref arr , 5);
https://msdn.microsoft.com/en-us/library/bb348051(v=vs.110).aspx
You could also implement private List<int> numberList
Then return numberList.ToArray();
in getter.
Upvotes: 1