Quantcast
Channel: Best way to "push" into C# array - Stack Overflow
Viewing all articles
Browse latest Browse all 13

Answer by aloisdg for Best way to "push" into C# array

$
0
0

The is no array.push(newValue) in C#. You don't push to an Array in C#. What we use for this is a List<T>. What you may want to consider (for teaching purpose only) is the ArrayList (no generic and it is a IList, so ...).

static void Main(){    // Create an ArrayList and add 3 elements.    ArrayList list = new ArrayList();    list.Add("One"); // Add is your push    list.Add("Two");    list.Add("Three");}

Viewing all articles
Browse latest Browse all 13

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>