COMや剰余類についての知識があまりないので、なぜnew
インターフェイスで演算子を使用できるのかよくわかりません。言語/フレームワークにとらわれない観点から、これが正しくコンパイルおよび実行される理由は混乱しています。
using Microsoft.Office.Interop.Excel;
public class ExcelProgram
{
static void Main(string[] args)
{
Application excel = new Application();
}
}
Visual Studio 2010で検査Application
すると、次のことがわかります。
using System.Runtime.InteropServices;
namespace Microsoft.Office.Interop.Excel
{
// Summary:
// Represents the entire Microsoft Excel application.
[Guid("000208D5-0000-0000-C000-000000000046")]
[CoClass(typeof(ApplicationClass))]
public interface Application : _Application, AppEvents_Event
{
}
}
舞台裏で何が起こっているのですか?