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

C#

 
GeneralRe: Question on xml encoding in C# Pin
Bugoy10-Jan-03 8:27
Bugoy10-Jan-03 8:27 
GeneralRe: Question on xml encoding in C# Pin
Stephane Rodriguez.10-Jan-03 22:51
Stephane Rodriguez.10-Jan-03 22:51 
GeneralRe: Question on xml encoding in C# Pin
leppie10-Jan-03 23:12
leppie10-Jan-03 23:12 
GeneralRe: Question on xml encoding in C# Pin
Stephane Rodriguez.10-Jan-03 23:42
Stephane Rodriguez.10-Jan-03 23:42 
GeneralRe: Question on xml encoding in C# Pin
leppie11-Jan-03 0:08
leppie11-Jan-03 0:08 
GeneralRe: Question on xml encoding in C# Pin
Stephane Rodriguez.11-Jan-03 2:02
Stephane Rodriguez.11-Jan-03 2:02 
GeneralSerialization Question Pin
matthias s.9-Jan-03 9:04
matthias s.9-Jan-03 9:04 
GeneralRe: Serialization Question Pin
leppie9-Jan-03 9:23
leppie9-Jan-03 9:23 
public class Class1
{
   public int number;
   public string name;

   [STAThread]
   static void Main(string[] args)
   {
      Class1 c = new Class1();
      c.name = "Hello";
      c.number = 1;

      XmlSerializer xser = new XmlSerializer(c.GetType());
      FileStream fs = File.Open("Class.xml", FileMode.OpenOrCreate);
      xser.Serialize(fs, c);

      fs.Close();
   }
}

Make sure class is public and the properties you want is public and the class must have a default constructor.

And the output:
<?xml version="1.0"?>
<Class1 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <number>1</number>
  <name>Hello</name>
</Class1>

CHeers Smile | :)

WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.

GeneralRe: Serialization Question Pin
matthias s.9-Jan-03 11:32
matthias s.9-Jan-03 11:32 
QuestionSerious Coding? Pin
FruitBatInShades9-Jan-03 6:48
FruitBatInShades9-Jan-03 6:48 
AnswerRe: Serious Coding? Pin
David Stone9-Jan-03 8:16
sitebuilderDavid Stone9-Jan-03 8:16 
QuestionHowTo Enumerate a systems DSN's ? Pin
Steve Cox9-Jan-03 5:28
Steve Cox9-Jan-03 5:28 
Questionhow to move the position of selected item in a listbox? Pin
fretre9-Jan-03 4:05
fretre9-Jan-03 4:05 
AnswerRe: how to move the position of selected item in a listbox? Pin
leppie9-Jan-03 6:10
leppie9-Jan-03 6:10 
QuestionHow to assign image pair to toolbar buttons? Pin
Smitha Nishant9-Jan-03 3:09
protectorSmitha Nishant9-Jan-03 3:09 
QuestionHas somebody already finished a Managed DX project? Pin
Zinj8-Jan-03 21:34
sussZinj8-Jan-03 21:34 
AnswerRe: Has somebody already finished a Managed DX project? Pin
leppie8-Jan-03 22:42
leppie8-Jan-03 22:42 
AnswerRe: Has somebody already finished a Managed DX project? Pin
Steve Maier18-Jan-03 17:34
professionalSteve Maier18-Jan-03 17:34 
GeneralDebug Crash / Variable - error: cannot obtain value Pin
kman8-Jan-03 17:25
kman8-Jan-03 17:25 
GeneralRe: Debug Crash / Variable - error: cannot obtain value Pin
leppie8-Jan-03 22:45
leppie8-Jan-03 22:45 
GeneralRe: Debug Crash / Variable - error: cannot obtain value Pin
kman9-Jan-03 5:44
kman9-Jan-03 5:44 
GeneralLoading an assembly Pin
lustuyck8-Jan-03 11:43
lustuyck8-Jan-03 11:43 
GeneralRe: Loading an assembly Pin
lustuyck8-Jan-03 11:55
lustuyck8-Jan-03 11:55 
GeneralTable Information Pin
Jassim Rahma8-Jan-03 10:36
Jassim Rahma8-Jan-03 10:36 
GeneralMulti Columns comboBox Pin
Jassim Rahma8-Jan-03 10:32
Jassim Rahma8-Jan-03 10:32 

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.