title: boxing on structs when calling ToString()
body: <p>I've often wondered if the following scenario actually happens in c# </p>
  
  <p>If I have a struct but I don't explicitly override any of the methods that derived from object such as ToString(), GetHashCode(), etc then if I declare a local instance of my struct class and call 'ToString()' on it, would my struct get boxed i.e would the CLR convert it implicitly to an object on the heap and then call ToString()? Or is it clever enough to know that there's no implementation for that struct and ignore it?</p>
  
  <p>i.e</p>
  
  <pre><code>public struct Vector2D
  {
      public float m_x;
      public float m_y;
  
  
      ...... etc
  }
  
  
  void SomeFunc()
  {
    Vector2D aVec = new Vector2D();
    Console.WriteLine(aVec.ToString()); // &lt;-- does aVec get boxed here?
    ..... 
  }
  </code></pre>
  
  <p>== Edit - Update==
  Mehrdad's <a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.constrained.aspx" rel="noreferrer">link to MSDN</a>, whilst being useful has confused me slighly.
  I'll quote and see if any one can unpick this for me</p>
  
  <blockquote>
    <p>When a callvirt  method instruction
    has been prefixed by constrained 
    thisType, the instruction is executed
    as follows:</p>
    
    <p>If thisType is a reference type (as
    opposed to a value type) then ptr is
    dereferenced and passed as the 'this'
    pointer to the callvirt of method.</p>
    
    <p>If thisType is a value type and
    thisType implements method then ptr is
    passed unmodified as the 'this'
    pointer to a call  method instruction,
    for the implementation of method by
    thisType.</p>
    
    <p><strong>If thisType is a value type and
    thisType does not implement method
    then ptr is dereferenced, boxed, and
    passed as the 'this' pointer to the
    callvirt  method instruction.</strong></p>
  </blockquote>
  
  <p>So does that mean that if I don't explicitly implement ToString() on my struct type that it will fall into the last case and get boxed? Or am I mis-understanding it somewhere?</p>