Answer the question
In order to leave comments, you need to log in
How to make a dictionary in Unity like in Pyhton?
Hello!
Help me please, I don't know how to make a dictionary in Unity C# like in python (example): Please tell me
how to do it! d = {'dict': 1, 'dictionary': 2}
Answer the question
In order to leave comments, you need to log in
It is possible so, types in pair can be any to substitute.
Dictionary<int, StudentName> students = new Dictionary<int, StudentName>()
{
{ 111, new StudentName { FirstName="Sachin", LastName="Karnik", ID=211 } },
{ 112, new StudentName { FirstName="Dina", LastName="Salimzianova", ID=317 } },
{ 113, new StudentName { FirstName="Andy", LastName="Ruth", ID=198 } }
};
Alexander , in fact, correctly pointed out to you.
it would only be necessary to make a reservation that in python there are all these immutable)) as pythonists love.
Anything can be a key and anything can be a value, even different types of keys in the layouts of the same dictionary ))
and the dictionary in C # is more strict.
something in the spirit
>>> foo = {42: 'aaa', 2.78: 'bbb', True: 'ccc'}
>>> foo
{42: 'aaa', 2.78: 'bbb', True: 'ccc'}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question