c# - How to use deserialized object? -


i serializing , deserializing object in c# windows 8 apps.

i serializing object before passing next view, because passing object throws out exceptions.

function onnavigatedto:

protected override void onnavigatedto(navigationeventargs e) {    base.onnavigatedto(e);    string xmlstring = e.parameter.tostring();    var thischannel = xmldeserializefromstring(xmlstring, typeof(channel));  ....} 

deserializing function:

  public static channel xmldeserializefromstring<channel>(string objectdata)     {         return (channel)xmldeserializefromstring(objectdata, typeof(channel));     }      public static object xmldeserializefromstring(string objectdata, type type)     {         var serializer = new xmlserializer(type);         object result;          using (textreader reader = new stringreader(objectdata))         {             result = serializer.deserialize(reader);         }          return result;     } 

object content

i want access data in object, like: thischannel.name doesn't work. , don't know how can continue working object.

start dropping var in line:

 //var thischannel = xmldeserializefromstring(xmlstring, typeof(channel));  channel thischannel = xmldeserializefromstring(xmlstring, typeof(channel)); 

and @ least error when wrong object xmldeserializefromstring() selected.

and sure use right one:

 channel thischannel = xmldeserializefromstring<channel>(xmlstring); 

overloading should used care , not mixed type parameters.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -