title: How to define named Parameters C#
body: <p>This seems like a simple question, but for some reason I can't find the answer anywhere. Basically, I'd like to be able to implement a constructor that takes <strong>NamedParameters</strong>. </p>
  
  <p>By named parameters, I do not mean parameters with default values (optional parameters) such as:</p>
  
  <pre><code>public SomeMethod(){
      string newBar = Foo(bar2 : "customBar2");
  }
  
  public string Foo(string bar1 = "bar1", bar2 = "bar2" ){
       //...
  }
  </code></pre>
  
  <p>A good example of what I'm trying to achieve is the <strong>AuthorizeAttribute</strong> from the <strong>System.Web.Mvc</strong> assembly. Which you can use the following way:</p>
  
  <pre><code>[Authorize(Roles = "Administrators", Users = "ThatCoolGuy")]
  public ActionResult Admin(){
  
  }
  </code></pre>
  
  <p>The constructor's signature in intellisense looks like the following example and I believe (please confirm) that those NamedParameters are mapping to class properties.</p>
  
  <blockquote>
    <p>AuthorizeAttribute.AuthorizeAttribute(<strong>NamedParameters...</strong>)
    Initiliaze new instance of the System.Web.Mvc.AuthorizeAttribute class</p>
    
    <p><strong>Named parameters:</strong></p>
    
    <ul>
    <li>Order int</li>
    <li>Users string</li>
    <li>Roles string</li>
    </ul>
  </blockquote>