What I Learned Today

No frills, just learn

Posts in the C-sharp category

C# Lists and Dictionary

In C# there are several key differences to C++. Microsoft Website spells them all: https://msdn.microsoft.com/en-us/magazine/cc301520.aspx

Garbage collector instead of deconstructors providing a different approach to micromenagment of memory and lists, jagged arrays and dynamic memory allocation are already available into the language. It supports also negative index to counting from the last element, similarly to Python.

About lists instead of the usual self-made textbook-example class, there are specific embedded classes for Lists and Dictionaries.

List<type> name = new List<type>();
name.Add(element);
name.Remove(element);

Dictionary<type,type> name = new Dictionary<type,type>();
name.Add(key,element);
name.Remove(key,element);