Z
Z
Zefirot2021-07-04 19:18:23
C++ / C#
Zefirot, 2021-07-04 19:18:23

Why doesn't it check if the key is in the dictionary?

here is my dictionary

private Dictionary<int, int> CellsMoove = new Dictionary<int, int>();

I check if there is no such value, then I enter, if there is, then I replace
int Num1 = 1;
int Num2 = 2;
if(!CellsMoove.ContainsKey(Num1)) CellsActive.Add(Num1, Num2); else CellsMoove[Num1] = Num2;

but it gives me an error
Argument 2: cannot convert from 'int' to 'bool'

Is ContainsKey supposed to return true or false , or what's wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question