title: Excel interop: _Worksheet or Worksheet?
body: <p>I'm currently writing about dynamic typing, and I'm giving an example of Excel interop. I've hardly done any Office interop before, and it shows. The <a href="http://msdn.microsoft.com/en-us/library/dd264733(VS.100).aspx" rel="noreferrer">MSDN Office Interop tutorial</a> for C# 4 uses the <code>_Worksheet</code> interface, but there's also a <code>Worksheet</code> interface. I've no idea what the difference is.</p>
  
  <p>In my absurdly simple demo app (shown below) either works fine - but if best practice dictates one or the other, I'd rather use it appropriately.</p>
  
  <pre><code>using System;
  using System.Linq;
  using Excel = Microsoft.Office.Interop.Excel;
  
  class DynamicExcel
  {
      static void Main()
      {
          var app = new Excel.Application { Visible = true };
          app.Workbooks.Add();
  
          // Can use Excel._Worksheet instead here. Which is better?
          Excel.Worksheet workSheet = app.ActiveSheet;
  
          Excel.Range start = workSheet.Cells[1, 1];
          Excel.Range end = workSheet.Cells[1, 20];
          workSheet.get_Range(start, end).Value2 = Enumerable.Range(1, 20)
                                                             .ToArray();
      }
  }
  </code></pre>
  
  <p>I'm trying to avoid doing a full deep-dive into COM or Office interoperability, just highlighting the new features of C# 4 - but I don't want to do anything really, really dumb.</p>
  
  <p>(There may be something really, really dumb in the code above as well, in which case please let me know. Using separate start/end cells instead of just "A1:T1" is deliberate - it's easier to see that it's genuinely a range of 20 cells. Anything else is probably accidental.)</p>
  
  <p>So, should I use <code>_Worksheet</code> or <code>Worksheet</code>, and why?</p>