In order to be consistent in the game dev environment, I try to convert JS to C# and have the following problem, apparently with the ToBuiltin function:
The original Code in JS from the book:
public function SaveGame (scores : int, name : String) : void {
//Submitting the score if the score is higher than the minimum score of the database
if (scores >= int_minScore) {
var a_newData : Array = new Array(as_users);
//Removing the last Array
a_newData.Pop();
//Creating new user and save it to array
var obj_user : UsersData = new UsersData();
obj_user.Init(name, scores);
a_newData.Add(obj_user);
//Setting JS Array back to Builtin
as_users = a_newData.ToBuiltin(UsersData);
//Sorting Data
SortUser(as_users);
}
for (var i: int = 0; i < int_maxUser; i++) {
as_users*.SaveLocal(i);*
-
}*
-
}*
Now, my translation: -
public void SaveGame(int scores, string name)*
-
{*
-
if(scores >= int_minScore)*
-
{*
-
ArrayList a_newData = new ArrayList(as_users);*
-
a_newData.RemoveAt(int_maxUser - 1);*
-
UsersData obj_user = new UsersData();*
-
obj_user.Init(name, scores);*
-
a_newData.Add(obj_user);*
-
as_users = a_newData.ToArray(UsersData);*
-
SortUser(as_users);*
-
}*
-
for( int i = 0; i < int_maxUser; i++)*
-
{*
as_users*.SaveLocal(i);
_ }_
_ }*_
Can somebody help me with the right conversion? Thank you.