Click here to Skip to main content
16,004,806 members
Home / Discussions / C#
   

C#

 
AnswerRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Pete O'Hanlon11-Nov-15 23:16
mvePete O'Hanlon11-Nov-15 23:16 
GeneralRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
John Torjo12-Nov-15 2:56
professionalJohn Torjo12-Nov-15 2:56 
GeneralRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Dave Kreskowiak12-Nov-15 4:10
mveDave Kreskowiak12-Nov-15 4:10 
GeneralRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Member 1212766512-Nov-15 2:58
Member 1212766512-Nov-15 2:58 
AnswerRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Richard Andrew x6412-Nov-15 3:08
professionalRichard Andrew x6412-Nov-15 3:08 
AnswerRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Bernhard Hiller12-Nov-15 4:12
Bernhard Hiller12-Nov-15 4:12 
GeneralRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
BillWoodruff12-Nov-15 5:45
professionalBillWoodruff12-Nov-15 5:45 
AnswerRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
BillWoodruff12-Nov-15 6:03
professionalBillWoodruff12-Nov-15 6:03 
You can use WCF (DataContract and DataMember) to serialize structures like this; in fact, I've written a very similar tree-structure, with internal Dictionaries, and it serializes/de-serializes okay. Compressing the XML output of the WCF serializer with GZip results in file sizes often less than 50% of the umcompressed file, and often with file sizes as low as 25% of the uncompressed XML. Those file sizes are comparable to the size of the structure(s) saved with binary serialization.

I gave an example of using WCF on a recent answer to a QA question here: ^].

Do read the documentation on using WCF; and study the various fields of the DataContract and DataMember Attributes that are optional; they are very useful !

Also, note that if your Class inherits from some Generic Collection, like this:
C#
[DataMember]
public class MyClass : List<SomeOtherClass>
{
     [DataMember]
     public int SomeIntProp { get; set; }
}
This will not serialize, even if 'SomeOtherClass is also properly adorned with WCF Attributes. I've never found an explanation of this.

So, code the generic Collection as a Property in another Class.

Suggestion: use Properties, not Fields.

Another idea: Here you'll find an implementation of a Generic approach to using WCF ... the code was inspired by the comments and ideas of Pete O'Hanlon on that thread, but if the code doesn't work for you, that's my fault Smile | :)

[^]
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.


modified 12-Nov-15 17:15pm.

AnswerRe: in c#. how to serilialize and deserialize object with object of other classes inside it??? Pin
Member 1212766512-Nov-15 21:26
Member 1212766512-Nov-15 21:26 
Questionrun file with associated extension in current instance (ddeexec?) Pin
robinsc10-Nov-15 9:51
robinsc10-Nov-15 9:51 
AnswerRe: run file with associated extension in current instance (ddeexec?) Pin
John Torjo10-Nov-15 10:21
professionalJohn Torjo10-Nov-15 10:21 
GeneralRe: run file with associated extension in current instance (ddeexec?) Pin
robinsc10-Nov-15 11:10
robinsc10-Nov-15 11:10 
GeneralRe: run file with associated extension in current instance (ddeexec?) Pin
John Torjo10-Nov-15 11:31
professionalJohn Torjo10-Nov-15 11:31 
GeneralRe: run file with associated extension in current instance (ddeexec?) Pin
Eddy Vluggen10-Nov-15 14:22
professionalEddy Vluggen10-Nov-15 14:22 
GeneralRe: run file with associated extension in current instance (ddeexec?) Pin
John Torjo11-Nov-15 4:15
professionalJohn Torjo11-Nov-15 4:15 
AnswerRe: run file with associated extension in current instance (ddeexec?) Pin
Bernhard Hiller12-Nov-15 4:16
Bernhard Hiller12-Nov-15 4:16 
QuestionWindows App for NGO Pin
COder87610-Nov-15 7:01
COder87610-Nov-15 7:01 
AnswerRe: Windows App for NGO Pin
Gerry Schmitz10-Nov-15 8:00
mveGerry Schmitz10-Nov-15 8:00 
AnswerRe: Windows App for NGO Pin
Richard MacCutchan10-Nov-15 8:39
mveRichard MacCutchan10-Nov-15 8:39 
AnswerRe: Windows App for NGO Pin
BillWoodruff10-Nov-15 14:32
professionalBillWoodruff10-Nov-15 14:32 
QuestionMissingManifestResourceException Pin
Rob Shields10-Nov-15 2:58
Rob Shields10-Nov-15 2:58 
AnswerRe: MissingManifestResourceException Pin
OriginalGriff10-Nov-15 3:32
mveOriginalGriff10-Nov-15 3:32 
AnswerRe: MissingManifestResourceException Pin
phil.o10-Nov-15 4:54
professionalphil.o10-Nov-15 4:54 
Questionhow to get Image from DataSet Pin
goldsoft10-Nov-15 0:29
goldsoft10-Nov-15 0:29 
AnswerRe: how to get Image from DataSet Pin
John Torjo10-Nov-15 0:40
professionalJohn Torjo10-Nov-15 0:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.