title: how to get list of devices for class device with only getter and parameterize constructor
body: <p>I am traversing the Xdocument and getting the attribute value for device name and IP and would like to get a list of device with device name and IP.</p>
  
  <p>My Device class has only getter and  parameterize constructor,</p>
  
  <pre><code> public class Device
  {
      private string _deviceName;
      private string _ip;
      public Device(string ip, string deviceName)
      {
          _ip = ip;
          _deviceName = deviceName;
      }
  
      public string DeviceName
      {
          get { return _deviceName; }
  
      }
  
      public string IP
      {
          get { return _ip; }
      }
  }
  </code></pre>
  
  <p>And here is the code to generate the list of devices, currently it has error, what we need to do here,</p>
  
  <pre><code> class Program
  {
      static void Main(string[] args)
      {
          try
          {
              string testData = @"&lt;?xml version=""1.0""?&gt;
                                  &lt;SSPReturnMessage&gt;
                                          &lt;DeviceList&gt;
                                              &lt;Device SN=""RX1""&gt;
                                              &lt;PL N=""XYZ"" Vn=""PQR""/&gt;
                                              &lt;IP&gt; 192.168.201.248 &lt;/IP &gt;
                                             &lt;DN&gt;&lt;![CDATA[device name]]&gt;&lt;/DN&gt;
                                              &lt;/Device&gt;
                                          &lt;/DeviceList&gt;
                                  &lt;/SSPReturnMessage&gt;";
  
              XDocument xDoc = XDocument.Parse(testData);
  
              var devices = xDoc.Descendants("Device")
              .Select(x =&gt;
                  new Device
                  {
                      DeviceName = x.Element("IP").Value,
                      IP = x.Element("DN").Value,
  
                  }).ToList();
  
  
          }
          catch (Exception ex)
          {
              Console.WriteLine(ex);
          }
  
          Console.ReadLine();
      }
  }
  </code></pre>