Serialization in C# is the process of converting an object into a stream of bytes to store the object to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization. Jun 21, 2015 I need some suggestions on how to import data into multiple list objects using Dapper and then serialize the lists into proper JSON format. Please share your suggestions.
I have this, and i want to serialize to xml both lists :
I used SerializeToXML method that i found in other tutorial but when i run it an error shows up
'Error 1 Inconsistent accessibility: parameter type 'System.Collections.Generic.List' is less accessible than method 'AppPrueba.Form1.SerializeToXML(System.Collections.Generic.List)' C:Users722825DesktopSanti CosasAppPruebaAppPruebaForm1.cs 27 28 AppPrueba'
Feb 01, 2002 Once a stream is open we create a BinaryFormatter and use the Serialize method to serialize our object to the stream. What Serialize method would do? It converts our object into binary format and streams it in. // Open a file and serialize the object into it in binary format. // EmployeeInfo.osl is the file that we are creating.
It will tell the code that generates the overrides: “Hey, if you ever need to deserialize a list, or array of these type of object, the surrounding tag name should be allCustomers”. So you do need to add this new attribute to the classes which you know will become members of a list to be deserialized.
Thanks in advance if you can help me!
user2115574user2115574
3 Answers
All the classes that you are trying to serialize to xml should be public. And for collection serialization you cannot use generics - either use untyped collections, like, ArrayList , or create a non-generic descendant class form List .