- Home /
Problem is not reproducible or outdated
JS: Dictionary is not a generic definition error...
Hi to all!
Ive just started using generics, lists work fine, dictionaries give me this error code. Help would be great!
var myDic : Dictionary.<String,int> = new Dictionary.<String,int>();`
No one? Nobody? Eric5h5, Statement, Bunny, by the powers of the newbie, I invoke thee!
But does it deserve an up vote? Lol...Still stuck with this.
Idk, I can't vote on anything cuz I'm still a level 1 forum character.
I think you should post a few more lines of code from above and below the line you've listed.
Including the full message from the compiler might help, too.
Answer by jahroy · Dec 14, 2011 at 09:45 PM
If I paste your code into my project it works fine.
Do you have a syntax error (like a forgotten semi-colon) on the line above or something?
Agreed.
Still, it works for me.
I assume you're including System.Collections.Generic....
Answer by Eric5h5 · Dec 14, 2011 at 10:18 PM
import System.Collections.Generic;
...
var myDic = new Dictionary.<String,int>();
You should import the System.Collections.Generic namespace when using List too, since not everything is available without it.
I am importing... and I still can't declare myDic without pissing off the compiler.
@gregzo - your code works for me if I paste it into my project exactly as you list it.
Answer by gregzo · Dec 14, 2011 at 10:46 PM
After a full reboot, the error doesn't show up anymore. Same code... Had tried restarting unity, hadn't worked. Thanks for the support! Does this kind of quirk happen often?
I've never seen that happen; maybe it was an old error that you hadn't cleared.
I think Eric is saying you may have just been seeing a runtime error that was left in the console.
Some errors disappear when you fix them. Others stay there until you clear the console... Or maybe reboot your computer.
There are also times when little green elves sneak into the room and change the way the compiler works.
Even if compiler elves don't exist, I think I've proven they don't appreciate my var na$$anonymous$$g humour... Still lost a full friggin hour on that silly error! Grrr...
Follow this Question
Related Questions
Accessing float from dictionary 2 Answers
Help understanding this generic list in JS. 1 Answer
Storing XML node and accessing from a dictionary 0 Answers
Need help converting js to C# -- yield return WaitForSeconds 3 Answers
Converting JS to C# 3 Answers