In Python I remember using dictionaries to make a list of variables so i could later select a random one… How is this done in c#.
Do you mean the dictionary class? Dictionary<TKey,TValue> Constructor (System.Collections.Generic) | Microsoft Learn
What do you mean by ‘select a random one’? Via a random integer that was generated by a method? That’d be an array or some kind of list.
A dictionary in C# is a key-value collection, it’s a generic type that allows to you store a value of any type associated with a unique key of any type, that could be a string for example, but also any other type.
For random selection a list is faster.
ok then how do you use lists in c#
List name = new List();
name.Add(value);
Read more about it here:
that doesn’t seem to work. could anyone just put an example with a list and random values from that list. I want the list to be full of game objects
What doesn’t work? If you can’t seem to use a list make sure you have a using for System.Collections.Generic
+1, seriously I don’t get why people can’t google such basic stuff and would rather wait 45 minutes for someone to answer on a forum…
because pepole can explain better in forums XD
that is the problem.