title: Default value C# class
body: <p>I have a function in a controller, and I receive the information for a form. I have this code:</p>
  <pre><code>public Actionresult functionOne(string a, string b, string c = &quot;foo&quot; )
  </code></pre>
  <p>I tried to convert this to a class like</p>
  <pre><code>public class bar
  {
      public string a {get;set;}
      public string b {get;set;}
      public string c {get;set;}
  }
  </code></pre>
  <p>and receive them as a object</p>
  <pre><code> public Actionresult functionOne(bar b)
  </code></pre>
  <p>Also I tried to put the defaultvalue in 'c' but is not working, I tried this:</p>
  <pre><code>public class bar
  {
      public string a {get;set;}
      public string b {get;set;}
      [System.ComponentModel.DefaultValue(&quot;foo&quot;)]
      public string c {get;set;}
  }
  </code></pre>
  <p>Nothing happened with that, I receive it as <code>null</code></p>
  <p>also I tried</p>
  <pre><code>public class bar
  {
      public string a {get;set;}
      public string b {get;set;}
      public string c 
      {
          get
          {
              return  c;
          }
          set
          {
              c=&quot;foo&quot;; //I also tried with value
          }
      }
  }
  </code></pre>
  <p>What should I do to write this default value?</p>