title: C# - Serialize multiple objects of the same class
body: <p>I am working on a small utility to manage a few computers connected on a network. This utility will have a button "Add Computer" on the UI which allows the user to configure a new computer.</p>
  
  <p>I have a class called component:</p>
  
  <pre><code>public class component
  {
  
  public string name { get; set; }
  public string ip { get; set; }
  public string room { get; set; }
  
  bla bla
  
  
  }
  </code></pre>
  
  <p>Please keep I am absolutely not a professional, so forgive me if the question sounds stupid.</p>
  
  <p>The first problem I got is: How can I create multiple instances of the same class at runtime? What I figured out is using a deep clone, with serialiazation and deserialization. Is it a good approach?</p>
  
  <p>Second problem. Let's say at runtime I managed to create my clones and I have an object for every computer in my network. How can I create a file containing all those objects? How can I serialize them?</p>
  
  <p>I am not looking for code, but just for someone pointing me in the right direction, as I am pretty sure my approach is not exactly the best. All suggestions are welcome.</p>
  
  <p>Thanks a lot!</p>