int[] userIds;
int[] userIds = new int[3];
userIds[0] = 104;
104
string[] names = new string[3] { "Johannes", "Rene", "Ville" };
double[] balances = new double[] { 1.3, 200.3, 9332.14 };
char[,] letters = new char[3, 4] { {'a', 'b', 'c', 'd'}, {'e', 'f', 'g', 'h'}, {'i', 'j', 'k', 'l'} }; Console.WriteLine(letters[1, 3]); // Outputs "h"
System.Collections.Generic
using System.Collections.Generic;
List<int> userIds = new List<int>();
userIds[0] = 22;
List<int> intList = new List<int>() { 1, 9, 4 }; intList.Remove(0); // List is now [9, 4] int[] intArray = new int[] { 1, 9, 4 }; intArray.Remove(0); // Can't do that, array is static // and doesn't include such method
string[] names = new string[] { "Harry Potter", "Luke Skywalker", "Harley Quinn" }; for (int i = 0; i < names.Length; ++i) { Console.WriteLine(names[i]); }
List.Count
Array.Length
List<int> numbers = new List<int>() { 1, 5, 3 }; int sum = 0; for (int i = 0; i < numbers.Count; ++i) { sum += numbers[i]; } // sum is now 9
foreach
string[] names = new string[] { "Harry Potter", "Luke Skywalker", "Harley Quinn" }; foreach (string name in names) { Console.WriteLine(name); }
add
list
remove
int.Parse()
Assignments about this topic can be found here