Click here to Skip to main content
15,914,014 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sending and Receiving Data Pin
Heath Stewart11-Jun-04 3:58
protectorHeath Stewart11-Jun-04 3:58 
GeneralRe: Sending and Receiving Data Pin
Richard Beacroft11-Jun-04 6:55
Richard Beacroft11-Jun-04 6:55 
GeneralAny Idea Pin
sreejith ss nair10-Jun-04 20:29
sreejith ss nair10-Jun-04 20:29 
GeneralRe: Any Idea Pin
Corinna John10-Jun-04 23:13
Corinna John10-Jun-04 23:13 
GeneralRe: Any Idea Pin
Heath Stewart11-Jun-04 3:47
protectorHeath Stewart11-Jun-04 3:47 
GeneralChanging the look of a row of datagrid on mouseover Pin
rajeev_mr10-Jun-04 19:34
rajeev_mr10-Jun-04 19:34 
GeneralRe: Changing the look of a row of datagrid on mouseover Pin
Heath Stewart11-Jun-04 3:45
protectorHeath Stewart11-Jun-04 3:45 
GeneralXML Serialization & Deserialization Pin
khchan10-Jun-04 18:40
khchan10-Jun-04 18:40 
Hi all,

I wanna serialize an object into an XML document. However the XmlSerializer Class doesn't handle the private data for me.

so I write the follow codes for serialization

XmlTextWriter writer = new XmlTextWriter(new StreamWriter("TestFile.txt"));
writer.Formatting = Formatting.Indented;
WriteQuote(writer, symbol, price, change, volume);
writer.Close();

static void WriteQuote(XmlWriter writer, string symbol,
double price, double change, long volume)
{
writer.WriteStartElement("Stock");
writer.WriteAttributeString("Symbol", symbol);
writer.WriteElementString("Price", XmlConvert.ToString(price));
writer.WriteElementString("Change", XmlConvert.ToString(change));
writer.WriteElementString("Volume", XmlConvert.ToString(volume));
writer.WriteEndElement();
}


and the following codes for deserialization

XmlTextReader reader = new XmlTextReader("TestFile.txt");
ReadQuote(reader);
reader.Close();

static void ReadQuote(XmlReader reader)
{
double price = 0, change = 0;
int volume = 0;
string attribute = "";

reader.MoveToContent();

while(reader.Read())
{
if(reader.Name == "Price")
price = Double.Parse(reader.ReadElementString());
if(reader.Name == "Change")
change = Double.Parse(reader.ReadElementString());
if(reader.Name == "Volume")
volume = Int32.Parse(reader.ReadElementString());
}


Is there any simpler way to do it?

Thanks Cool | :cool:
GeneralRe: XML Serialization & Deserialization Pin
Heath Stewart11-Jun-04 3:37
protectorHeath Stewart11-Jun-04 3:37 
Generaladding a Menu bar log Pin
samithas10-Jun-04 18:18
samithas10-Jun-04 18:18 
QuestionHow does ImageIndex property works Pin
luming112233445510-Jun-04 17:42
luming112233445510-Jun-04 17:42 
AnswerRe: How does ImageIndex property works Pin
Nick Seng10-Jun-04 21:30
Nick Seng10-Jun-04 21:30 
GeneralRe: How does ImageIndex property works Pin
Heath Stewart11-Jun-04 3:30
protectorHeath Stewart11-Jun-04 3:30 
AnswerRe: How does ImageIndex property works Pin
Heath Stewart11-Jun-04 3:29
protectorHeath Stewart11-Jun-04 3:29 
GeneralRe: How does ImageIndex property works Pin
luming112233445513-Jun-04 16:17
luming112233445513-Jun-04 16:17 
GeneralRe: How does ImageIndex property works Pin
Heath Stewart13-Jun-04 17:52
protectorHeath Stewart13-Jun-04 17:52 
Generalincremental installation of C# application Pin
ting66810-Jun-04 15:52
ting66810-Jun-04 15:52 
GeneralRe: incremental installation of C# application Pin
Peter Vertes10-Jun-04 17:52
Peter Vertes10-Jun-04 17:52 
GeneralRe: incremental installation of C# application Pin
Anonymous11-Jun-04 19:00
Anonymous11-Jun-04 19:00 
GeneralProblem using embedded WMP to play file in C# Pin
Admiral Ackbar10-Jun-04 15:43
Admiral Ackbar10-Jun-04 15:43 
GeneralRe: Problem using embedded WMP to play file in C# Pin
User 96257810-Jun-04 17:21
User 96257810-Jun-04 17:21 
GeneralRe: Problem using embedded WMP to play file in C# Pin
Admiral Ackbar11-Jun-04 2:33
Admiral Ackbar11-Jun-04 2:33 
GeneralAlso..... Pin
User 96257812-Jun-04 7:17
User 96257812-Jun-04 7:17 
GeneralRe: Also..... Pin
Admiral Ackbar12-Jun-04 11:30
Admiral Ackbar12-Jun-04 11:30 
GeneralRe: Also..... Pin
User 96257812-Jun-04 17:08
User 96257812-Jun-04 17:08 

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.