title: C# is there a difference between passing a struct reference and a class reference to a method in terms of speed?
body: <p>As seen <a href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/how-to-know-the-difference-passing-a-struct-and-passing-a-class-to-a-method" rel="nofollow noreferrer">here</a>, structs are passed by copy and classes by reference. But why is passing a struct by reference using the ref keyword still slower than passing a reference to a class ?</p>
  
  <p>I got different speeds for my program by replacing the <code>struct</code> keywords with <code>class</code>. All of the variables were already passed with the <code>ref</code> keyword.<br />
  By changing keywords, I got  20% speed increase in my tests. Shoudn't the speed remain the same since I was already passing by reference ? What am I not understanding ?</p>