Arrays must be assigned a length. To allow for any number of elements, use the List
class.
For example:
List<int> myInts = new List<int>();
myInts.Add(5);
myInts.Add(10);
myInts.Add(11);
myInts.Count // = 3
More Related Contents:
- Sum multidimensional array over dimensions [closed]
- C# how to create an array of objects? [closed]
- how to write every element of an array in a line of a textbox C# [closed]
- Convert string[] to Array
- How can I get more than one random numbers in a specific range using C#?
- How do I divide an array into separate arrays in C#?
- Cannot deserialize the JSON array (e.g. [1,2,3]) into type ‘ ‘ because type requires JSON object (e.g. {“name”:”value”}) to deserialize correctly
- Remove element of a regular array
- Array slices in C#
- How do I concatenate two arrays in C#?
- How do I convert a Stream into a byte[] in C#? [duplicate]
- How to store int[] array in application Settings
- change array size
- Fast way to convert a two dimensional array to a List ( one dimensional )
- Passing Arrays by Value and by Reference
- How can I print the contents of an array horizontally?
- What is the use of the ArraySegment class?
- How to pass a single object[] to a params object[]
- How to add a string to a string[] array? There’s no .Add function
- Convert array of integers to comma-separated string
- C# Cast Entire Array?
- Why is there huge performance hit in 2048×2048 versus 2047×2047 array multiplication?
- Cannot deserialize the current JSON array (e.g. [1,2,3])
- Converting jagged array to 2D array C#
- Can’t create huge arrays
- How to check if a byte array is a valid image?
- Why is array co-variance considered so horrible?
- 2d Array from text file c# [closed]
- In C#, why Equals() method on arrays only compare their references, not their actual content
- How to copy a row of values from a 2D array into a 1D array?