title: Variables passed by reference to static method?
body: <p>I have some code that is behaving like my variables are being passed by reference when I don't think they should be. </p>
  
  <p>In a class library I have </p>
  
  <pre><code>public class ListingHelper
  {
      public static List&lt;FilterCategory&gt; getListingFilterCertifications(ListingCategory parentListingCategory, ListingFilters filters)
      {
         ...//Building up return object
         filters.gradingServiceId = 2;
      }
  
  }
  </code></pre>
  
  <p>In the pageLoad of a page I call this: </p>
  
  <pre><code>private void BindForm()
  {
     ListingFilters filters = new ListingFilters();
     filters.gradingServiceId = 0;
  
     if (filters.gradingServiceId &gt; 0)
     {
         listCertification.DataSource = ListingHelper.getListingFilterCertificationById(filters.gradingServiceId);
         listCertification.DataBind();
     }
  }
  </code></pre>
  
  <p>I thought that <code>filters.gradingServiceId</code> should be 0 when I get back from calling my method in the library, but it's coming back as 2. Are methods parameters to static methods really passed by reference?</p>
  
  <p>Listing Filters: </p>
  
  <pre><code>public class ListingFilters
  {
      public String state { get; set; }
      public int categoryId { get; set; }
      public int gradingServiceId { get; set; }
      public int gradeId { get; set; }
  }
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>Thanks for the link Jon. So it sounds like in .net all user created classes are reference types and even when passed by value you aren't actually sending a copy of the object but instead a pointer to its location in memory. </p>
  
  <p>If that's the case how would I pass a copy of my filters object to a method so that I can mess around with the values and have them not be affected in the code that called it?</p>