Answer the question
In order to leave comments, you need to log in
How to use Dictionary in Unity?
I'm making a store in my game. I found out that there is such a thing as a Dictionary, looked at how it's all done and wrote the following code in the unit:
var Сell = new Dictionary<string, int>(){
{ "Skin1" : 0},
};
But for some reason Visual Studio highlights this code in red. Why and how to solve it?
Answer the question
In order to leave comments, you need to log in
Because a syntax error. Specifically, a colon.
And because you must first learn the language, and then climb into the unit.
You have a syntax error here
var Сell = new Dictionary<string, int>(){
{ "Skin1" : 0}, // Вот здесь
};
var cell = new Dictionary<string, int>() {
{ "Skin1", 0 },
};
var cell = new Dictionary<string, int>() {
["Skin1"] = 0,
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question