list - Passing parameters with multiple objects -


so want pass in object list, have many different ones. (swords, chestplates etc). how can pass in multiple objects parameter?

listtosave = testobject.chestplatelist; part below part want pass object list into.

public void deserializefromxml(list<chestplate> listtosave, string filepath)         {             xmlserializer deserializer = new xmlserializer(typeof(gameobjectdata));             filestream fs = new filestream(filepath, filemode.open);             xmlreader reader = new xmltextreader(fs);              if (!reader.eof)             {                 gameobjectdata testobject = (gameobjectdata)deserializer.deserialize(reader);                 listtosave = testobject.chestplatelist;                 console.writeline("{0}", testobject.chestplatelist);                          }                 } 

try (untested)

public void serializetoxml(gameobjectdata thedata, string filepath) {     xmlserializer serializer = new xmlserializer(typeof(thedata));     textwriter writer = new streamwriter(filepath);     serializer.serialize(writer, listtosave); } 

and

public gameobjectdata deserializefromxml(string filepath) {     gameobjectdata result = null;     xmlserializer deserializer = new xmlserializer(typeof(gameobjectdata));     filestream fs = new filestream(filepath, filemode.open);     xmlreader reader = new xmltextreader(fs);      if (!reader.eof)     {         result = (list<gameobject>)deserializer.deserialize(reader);          console.writeline("{0}", result.chestplatelist);                   }        return result;      } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -