title: Assign a value from a string array to the string property of each element of a custom type array
body: <p>Suppose I have an array of strings - <code>countryNames[]</code> - containing the names of the countries in the world:</p>
  
  <pre><code>string[] countryNames = { "Afghanistan" , "Albania" , "Algeria", ... }
  </code></pre>
  
  <p>I also have a class called <code>Country</code> containing these properties, among others:</p>
  
  <pre><code>public string CountryCode { get; set; }
  public string Name { get; set; }
  </code></pre>
  
  <p>My goal is to create an array of the custom type <code>Country</code>, and assign to the <code>Country.Name</code> property of each element of <code>Country[]</code> the corresponding index's string value of <code>countryNames[]</code>. I tried doing so in the following way, in the same method where I implemented the string array:</p>
  
  <pre><code>Country[] countries = new Country[193];
  for (int i = 0; i &lt; 193; i++)
  {
      countries[i].Name = countryNames[i];
  }
  return countries;
  </code></pre>
  
  <p>The <code>countries[i].Name</code> however, causes a <code>NullReferenceException</code> . I can't see where the problem is though, as the property <code>Country.Name</code> is a string. Are there any complications when arrays and properties are mixed together?</p>
  
  <p>Thanks guys!</p>