I am using Silverlight
I have an error on intialising the object which is:
Error 1 Duplicate initialization of member 'Parameter' C:\Users\SHEK\Documents\Visual Studio 2012\Projects\SliderLastTry\SliderLastTry\ControlClass.cs 24 17 SliderLastTry
and it corresponds to second intialistion of Parameter:
Parameter = { new Parameter { Name = "Name2", Label = "Label2", Unit = "Uint2", Component = { new Component { Type = "Type2", Attributes = { new Attributes { Type = "Slider", Displayed = "52", Selected = "05", Items = { "20", "21", "22", "23", "24" } } } } } } }
I am trying to assign the intialise the object in Main function like this:
Parameter = { new Parameter { Name = "Name1", Label = "Label1", Unit = "Uint1", Component = { new Component { Type = "Type1", Attributes = { new Attributes { Type = "Combo", Displayed = "42", Selected = "02", Items = { "10", "11", "12", "13", "14" } } } } } } }
,
Separator = { new Separator { Separators = "AutoSkew1" } }
,
Parameter = { new Parameter { Name = "Name2", Label = "Label2", Unit = "Uint2", Component = { new Component { Type = "Type2", Attributes = { new Attributes { Type = "Slider", Displayed = "52", Selected = "05", Items = { "20", "21", "22", "23", "24" } } } } } } }
and
var memory = new MemoryStream();
var serial = new XmlSerializer(objectToSerialize.GetType());
serial.Serialize(memory, objectToSerialize);
var utf8 = new UTF8Encoding();
return utf8.GetString(memory.GetBuffer(), 0, (int)memory.Length);
I know the reason why i have this error. But the reason for doing like this even after being aware of it is:
(1) I have to display the xml in the same order as i have shown you. I mean Parameter then Separator an then again Parameter. But if i do intialize my object in the first intialization like Parameter = { new Parameter{..} , new Parameter{..}}
then it show next just after the but i want <separator>Auto Skewing</separator>
between these two .
How to do solve these 2 problems ? Please do not hesitate to ask me more if you still dont understand what i am tryin to do. Thanks a lot.
EDIT: I guess it can be done through XElement but how to manage the code for that i am still not able to understand.