title: Looping over an Enum is null
body: <p>I am following this tutorial (<a href="https://code-maze.com/factory-method/" rel="nofollow noreferrer">https://code-maze.com/factory-method/</a>) to learn more about Factory patterns in C#. I have the code:</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using FactoryPattern.Interfaces;
  
  namespace FactoryPattern
  {
      public class AirConditioner
      {
          private readonly Dictionary&lt;Actions, AirConditionerFactory&gt; _factories;
  
          public AirConditioner()
          {
              _factories = new Dictionary&lt;Actions, AirConditionerFactory&gt;();
  
              foreach(Actions action in Enum.GetValues(typeof(Actions)))
              {
                  var factory = (AirConditionerFactory)Activator.CreateInstance(Type.GetType(
                                  &quot;FactoryMethod.&quot; + Enum.GetName(typeof(Actions), action) + &quot;Factory&quot;));
  
                  _factories.Add(action, factory);
              }
          }
  
          public IAirConditioner ExecuteCreation(Actions action, double temperature) =&gt; _factories[action].Create(temperature);
      }
  }
  
  </code></pre>
  <p>My Actions Enum is as follows:</p>
  <pre><code>namespace FactoryPattern
  {
      public enum Actions
      {
          Cooling,
          Warming
      }
  }
  
  </code></pre>
  <p>My Cooling/Warming factories are like this:</p>
  <pre><code>
  namespace FactoryPattern
  {
      public class CoolingFactory : AirConditionerFactory
      {
           public override IAirConditioner Create(double temperature) =&gt; new CoolingManager(temperature);
      }
  }
  
  </code></pre>
  <p>When I run the code I get an error on the line <code>foreach(Actions action...</code> because 'action' is null. Am I missing something really obvious here?</p>