title: ASP.NET Core - how to inject IOptionsMonitor<T[]>
body: <p>How can I inject <code>IOptionsMonitor&lt;T[]&gt;</code> into a controller?</p>
  
  <p>In appsettings.json</p>
  
  <pre><code>{
        "MyArray": [
         {
            "Name": "Name 1",
            "SomeValue": "Value 1",
         },
         {
            "Name": "Name 2",
            "SomeValue": "Value 2",
         }
        ]
  }
  </code></pre>
  
  <p>In Startup.cs</p>
  
  <pre class="lang-cs prettyprint-override"><code>public void ConfigureServices(IServiceCollection services)
  {
       services.AddOptions();
       services.Configure&lt;MyOptions[]&gt;(Configuration.GetSection("MyArray"));
  }
  </code></pre>
  
  <p>In HomeController</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class HomeController : Controller
  {
      private readonly MyOptions[] myOptions;
      public HomeController(IOptionsMonitor&lt;MyOptions[]&gt; myOptions)
      {
          this.myOptions = myOptions.CurrentValue;
      }
  }
  </code></pre>
  
  <p>I'm getting 
  <code>Unable to resolve service for type 'Microsoft.Extensions.Options.IOptionsMonitor`1[MyOptions[]]' while attempting to activate 'Api.Controllers.HomeController'.</code> exception.</p>
  
  <p>I can access the configuration by <code>configuration.GetSection("MyArray").Get&lt;MyOptions[]&gt;()</code> and it works, but I would like to inject it as constructor parameter.</p>