Friday, 15 July 2011

c# - Passing an ObservableCollection as a parameter in a method to another class -



c# - Passing an ObservableCollection as a parameter in a method to another class -

i pass observablecollection parameter in method method in class. method phone call source class looks saveloadserialization.save(classdatas,connectors, filename);. classdatas , connectors both object. these objects defined in source class:

public observablecollection<classdata> classdatas { get; set; } public observablecollection<connector> connectors { get; set; }

the target class save-method exists looks this:

public void save(ilist _classdatas, ilist _connectors, string filename) { // classdata object seek { xmlserializer xsclassdata = new xmlserializer(typeof(observablecollection<classdata>)); <--- fails here if (_classdatas.count > 0) { using (streamwriter swclassdata = new streamwriter(filename)) { xsclassdata.serialize(swclassdata, _classdatas); } } } grab (exception e) { console.writeline(e.message); } // connector object seek { xmlserializer xsconnector = new xmlserializer(typeof(observablecollection<connector>)); <-- fails here if (_connectors.count > 0) { using (streamwriter swconnector = new streamwriter(filename)) { xsconnector.serialize(swconnector, _connectors); } } } grab (exception e) { console.writeline(e.message); } }

if alter line xmlserializer xsconnector = new xmlserializer(typeof(observablecollection<connector>)); xmlserializer xsconnector = new xmlserializer(typeof(observablecollection<_connectors>)); receive same error both of them: "the type or namespace name '_connectors' not found".

i cannot see why doesn't work?!

how solve problem?

thanks,

c# wpf object observablecollection

No comments:

Post a Comment