Click here to Skip to main content
15,900,110 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to invoke stored procedures in SQL server via form Pin
Eduard Keilholz20-Aug-07 2:48
Eduard Keilholz20-Aug-07 2:48 
QuestionChanging crystal report connection at runtime Pin
-spy-20-Aug-07 1:18
-spy-20-Aug-07 1:18 
AnswerRe: Changing crystal report connection at runtime Pin
sathish s20-Aug-07 3:14
sathish s20-Aug-07 3:14 
GeneralRe: Changing crystal report connection at runtime Pin
-spy-20-Aug-07 4:46
-spy-20-Aug-07 4:46 
AnswerRe: Changing crystal report connection at runtime Pin
mjmcinto20-Aug-07 3:49
mjmcinto20-Aug-07 3:49 
GeneralRe: Changing crystal report connection at runtime Pin
-spy-20-Aug-07 4:45
-spy-20-Aug-07 4:45 
Questionproblem in xmlserialization for arraylist Pin
cyn820-Aug-07 0:41
cyn820-Aug-07 0:41 
AnswerRe: problem in xmlserialization for arraylist Pin
Hessam Jalali20-Aug-07 2:12
Hessam Jalali20-Aug-07 2:12 
As far as i know if you put the attributes directly on the arraylist they don't work for giving the alternate name you set you must put them on classes and properties

here is an exapmle


if you write your code somewhat like this


[XmlArray("DataArray")]
[XmlArrayItem("DataArrayElement")]
ArrayList arr = new ArrayList();

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
arr.Add("Manoj");
arr.Add(4);
arr.Add(4.5);

XmlSerializer xmlSer = new XmlSerializer(arr.GetType());
FileStream fo=new FileStream(@"N:\xmlserTest.xml",FileMode.OpenOrCreate);

xmlSer.Serialize(fo,arr);
fo.Close();
}


the result would be like

<?xml version="1.0"?>
<ArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<anyType xsi:type="xsd:string">Manoj</anyType>
<anyType xsi:type="xsd:int">4</anyType>
<anyType xsi:type="xsd:double">4.5</anyType>
</ArrayOfAnyType>


and if you write it like this


[XmlRoot("MyData")]
public class MyData
{

ArrayList arr = new ArrayList();

[XmlArray("DataArray")]
[XmlArrayItem("DataArrayElement")]
public ArrayList TheData
{
get { return this.arr; }
}


public MyData()
{
arr.Add("Manoj");
arr.Add(4);
arr.Add(4.5);
}

public void Serialize()
{
XmlSerializer xmlSer = new XmlSerializer(typeof(MyData));
FileStream fo = new FileStream(@"N:\xmlserTest.xml", FileMode.OpenOrCreate);

xmlSer.Serialize(fo, this);
fo.Close();
}
}

the result would be

<?xml version="1.0"?>
<MyData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<DataArray>
<DataArrayElement xsi:type="xsd:string">Manoj</DataArrayElement>
<DataArrayElement xsi:type="xsd:int">4</DataArrayElement>
<DataArrayElement xsi:type="xsd:double">4.5</DataArrayElement>
</DataArray>
</MyData>

as a tip the XmlRoot Attribute just replace the name of the class with the alternate name


hope the post would be useful

good luck




GeneralRe: problem in xmlserialization for arraylist Pin
cyn820-Aug-07 15:09
cyn820-Aug-07 15:09 
GeneralRe: problem in xmlserialization for arraylist Pin
cyn820-Aug-07 16:51
cyn820-Aug-07 16:51 
QuestionLosing COM event handlers in C# [modified] Pin
Vitaly Tomilov20-Aug-07 0:14
Vitaly Tomilov20-Aug-07 0:14 
AnswerRe: Losing COM event handlers in C# Pin
Vitaly Tomilov20-Aug-07 1:28
Vitaly Tomilov20-Aug-07 1:28 
Questionunable to display MySQL DateTime DataType Values in Crystal Reports using C#.NET 2.0 XML Schema Pin
raju572520-Aug-07 0:08
raju572520-Aug-07 0:08 
QuestionCompatibility question Pin
Muammar©19-Aug-07 23:27
Muammar©19-Aug-07 23:27 
AnswerRe: Compatibility question [modified] Pin
Hessam Jalali19-Aug-07 23:55
Hessam Jalali19-Aug-07 23:55 
AnswerRe: Compatibility question Pin
Christian Graus19-Aug-07 23:57
protectorChristian Graus19-Aug-07 23:57 
AnswerRe: Compatibility question Pin
Mustafa Ismail Mustafa20-Aug-07 3:13
Mustafa Ismail Mustafa20-Aug-07 3:13 
QuestionWhat is the logic for WebService methods ? Pin
MehmetFurkan19-Aug-07 23:07
MehmetFurkan19-Aug-07 23:07 
AnswerRe: What is the logic for WebService methods ? Pin
Talal Sultan19-Aug-07 23:27
Talal Sultan19-Aug-07 23:27 
GeneralRe: What is the logic for WebService methods ? Pin
MehmetFurkan20-Aug-07 0:09
MehmetFurkan20-Aug-07 0:09 
GeneralRe: What is the logic for WebService methods ? Pin
Talal Sultan20-Aug-07 1:38
Talal Sultan20-Aug-07 1:38 
QuestionIs it possible to create an Access database with Pure C# Code Pin
Infernojericho19-Aug-07 23:04
Infernojericho19-Aug-07 23:04 
AnswerRe: Is it possible to create an Access database with Pure C# Code Pin
Christian Graus20-Aug-07 0:01
protectorChristian Graus20-Aug-07 0:01 
GeneralRe: Is it possible to create an Access database with Pure C# Code Pin
Syed Mujtaba Hassan20-Aug-07 2:51
Syed Mujtaba Hassan20-Aug-07 2:51 
AnswerRe: Is it possible to create an Access database with Pure C# Code Pin
Talal Sultan20-Aug-07 0:03
Talal Sultan20-Aug-07 0:03 

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.