C# allows you to seed data into your dictionary when it’s constructed by using an initializer function that accepts a series of key, value pairs after its constructor that causes those elements to be automatically inserted into your Dictionary’s for you. This is a really handy way to initialize your dictionaries if you already know what you expect to be a part of them or want to use a Dictionary as a lookup table for example.
An example of what this might look like:
|
|
Doing this traditionally would look like this:
|
|
This trick also works for Lists! Here’s how: https://youtu.be/F11BhVjmyd0
Join the World of Zero Discord server: https://discord.gg/hU5Kq2u