Sunday 15 January 2012

c# - write IEnumerable<IEnumerable > to file -


I'm having trouble finding out how to write this collection in the file I have the following classes < / P>

  Geographic rows of the public stable class {public static Observale Collection & lt; Connection & gt; Connection = New Observational Collection & lt; Connection & gt; (); } Public Square Connection {Public Inimerable & lt; IEnumerable & lt; Point & gt; & Gt; Number {get; Set; } Public Connection (Point P1, Point P2) {Points = New List & lt; List & lt; Point & gt; & Gt; {New list & lt; Point & gt; {P1, P2}}; }}   

and then some things like this:

  GeoPolyLines.connections.Add (new connection (new point (geographic location. Location [0] Target, Geolocation Location. [0]. Letitid), New point (geographical location. Location [1]. Longitude, geographical location. Location [1]. Latitude))); Then at the end of GeoPolyLines.connections I would again have a bunch of different locations that I want to write to save and reload to .txt file. But I do not know how to do it. I have something like:  
 using  (streamer SW = new streamer (filename)) {var enumerator = GeoPolyLines.connections.GetEnumerator (); While (counter. Headbook ()) {} sw.Close (); }    

Use the serialization.

Write to file

  var serializer = new JavaScriptSerializer (); File. Write all text (file name, serializer. Serialize);   

and to read from the file

  var points = serializer Dairyialize & lt; List & lt; Point & gt; & Gt; (File .ReadList (file name));    

No comments:

Post a Comment