Click here to Skip to main content
15,891,316 members
Home / Discussions / C#
   

C#

 
GeneralPocket PC email client Pin
ppp00128-Feb-05 17:04
ppp00128-Feb-05 17:04 
Generalmy own collection Pin
(Steven Hicks)n+128-Feb-05 16:53
(Steven Hicks)n+128-Feb-05 16:53 
GeneralNamespaces Pin
Soumya Mulukutla28-Feb-05 16:15
Soumya Mulukutla28-Feb-05 16:15 
GeneralRe: Namespaces Pin
spif200128-Feb-05 20:19
spif200128-Feb-05 20:19 
GeneralRe: Namespaces Pin
Soumya Mulukutla1-Mar-05 2:51
Soumya Mulukutla1-Mar-05 2:51 
GeneralRe: Namespaces Pin
leppie1-Mar-05 3:54
leppie1-Mar-05 3:54 
Generalon using SSL Pin
ppp00128-Feb-05 15:57
ppp00128-Feb-05 15:57 
GeneralI XMLSerialized an arraylist aka differant objects to one file! :P Pin
FocusedWolf28-Feb-05 15:52
FocusedWolf28-Feb-05 15:52 
Ok i don't know how unknown this method is...or if i'm the last one to find out how...but i did it!

the secret lies in this:

[
XmlInclude(typeof(ClassToSerialize)),
XmlInclude(typeof(AnotherClass))
]
public class SerializableArrayList : ArrayList
{}

it was apparent from the errormessages that the serializer was struggling to determine the types of the objects it was trying to serialize...so if i use this class as my arraylist, and do the xmlinclude on any type my arraylist will hold, then i could serialize it. (i don't think it'd be possible to do this if you don't know the types...without making your own xml serializer)

This is what the serialized xml looks like. Notice the "AnotherClass"...this is the contents of an arraylist! and both serialization and deserialization works. Only thing i wish i could do is get rid of that anyType thing thats all over the place...if anyone knows how let me know...if anyone wants more code let me know...if you think this is good enough to be a article let me know :P

note: i had to double up on the xml braces, cause codeproject considers them page formating

<>
<<arrayofanytype xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">>
<<anytype xsi:type="ClassToSerialize">>
<<age>>3<>
<<name>>hi<>
<>
<<anytype xsi:type="ClassToSerialize">>
<<age>>4<>
<<name>>hi<>
<>
<<anytype xsi:type="ClassToSerialize">>
<<age>>5<>
<<name>>hi<>
<>
<<anytype xsi:type="AnotherClass">>
<<age>>666<>
<>
<<anytype xsi:type="ClassToSerialize">>
<<age>>6<>
<<name>>hi<>
<>
<>
GeneralSQL Join over two databases Pin
ppp00128-Feb-05 15:43
ppp00128-Feb-05 15:43 
GeneralRe: SQL Join over two databases Pin
turbochimp28-Feb-05 16:23
turbochimp28-Feb-05 16:23 
GeneralRe: SQL Join over two databases Pin
ppp00128-Feb-05 17:29
ppp00128-Feb-05 17:29 
GeneralWindows Forms ListBox &quot;GetItemValue&quot; method Pin
Anonymous28-Feb-05 14:54
Anonymous28-Feb-05 14:54 
Generalevents hold objects Pin
bob dole++28-Feb-05 14:39
bob dole++28-Feb-05 14:39 
QuestionHow to format the string Pin
oohungoo28-Feb-05 14:26
oohungoo28-Feb-05 14:26 
AnswerRe: How to format the string Pin
Rob Graham28-Feb-05 15:33
Rob Graham28-Feb-05 15:33 
Generalread Com+ components Pin
28-Feb-05 11:22
suss28-Feb-05 11:22 
Generalsql connection path help i need - pl see the code inside Pin
chandtec28-Feb-05 10:58
chandtec28-Feb-05 10:58 
GeneralConvert ListBox selectedvalue into INT Pin
vibyvej28-Feb-05 9:24
vibyvej28-Feb-05 9:24 
GeneralRe: Convert ListBox selectedvalue into INT Pin
Kwai Cheng Kane28-Feb-05 10:26
Kwai Cheng Kane28-Feb-05 10:26 
GeneralRe: Convert ListBox selectedvalue into INT Pin
vibyvej28-Feb-05 11:31
vibyvej28-Feb-05 11:31 
GeneralRe: Convert ListBox selectedvalue into INT Pin
Md Saleem Navalur28-Feb-05 19:41
Md Saleem Navalur28-Feb-05 19:41 
GeneralRe: Convert ListBox selectedvalue into INT Pin
vibyvej28-Feb-05 20:18
vibyvej28-Feb-05 20:18 
GeneralQuick Question&#8230; Pin
HahnTech28-Feb-05 9:13
HahnTech28-Feb-05 9:13 
GeneralRe: Quick Question&#8230; Pin
Dave Kreskowiak28-Feb-05 9:37
mveDave Kreskowiak28-Feb-05 9:37 
GeneralRe: Quick Question&#8230; Pin
adocoder28-Feb-05 10:12
adocoder28-Feb-05 10:12 

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.