- Home /
 
UnityScript How To Deserialize?
When I try to deserialize using this piece of code, it comes up with an error - there's no semicolon in the second line?
 var Binary : BinaryFormatter = new BinaryFormatter();
 var TempIntList = (List.<int>)Binary.Deserialize(File);
 
               Any ideas?
Answer by Benproductions1 · Nov 20, 2013 at 10:02 AM
Hello,
You seem to have gotten some confusion between UnityScript and C#
In C# generics are done using List and in UnityScript it's done using List.
And in C# casting is done using (type)value while in UnityScript it's value as type
You need to use the right syntax for the right language. You can't just mix and match ;)
Hope this helps,
Benproductions1 
ok, thanks for clearing that up for me, but how do I now deserialize in JS?
UnityScript casting isn't like C# casting. You'll have to use as to cast. You should also type all your variables ;) 
what do you mean 'as?' and thanks for continuing to help :)
In UnityScript, you can't do (type)value to cast it, ins$$anonymous$$d you need to do value as type ins$$anonymous$$d. 
Your answer
 
             Follow this Question
Related Questions
First time open error android game 0 Answers
What's this error? 1 Answer
JS Automaticly Unchecked Upon Instantiate 0 Answers
Boolean Errors 2 Answers
Help with Binary serialization/de-serialization of List items and the WEBPLAYER 1 Answer