CreateUser("admin", "pwd", , true); (以逗號佔位)CreateUser("admin", "pwd", 20, true); 或使用命名參數 CreateUser("admin", "pwd", isLocked: true);舊版需使用 Type.Missing 佔位省略參數:
var excelApp = new Microsoft.Office.Interop.Excel.Application();
var format = Microsoft.Office.Interop.Excel.XlRangeAutoFormat.xlRangeAutoFormatAccounting1;
excelApp.get_Range("A1", "B4").AutoFormat(format, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
C# 4.0 僅需:
excelApp.get_Range("A1", "B4").AutoFormat(Format: format);
嵌入強命名組件的介面類型資訊,使應用程式與獨立部署的執行時組件版本鬆散耦合。應用程式可在無重新編譯情況下使用多版本類庫。
[ComImport] 與 [Guid]。[ImportedFromTypeLib] 與組件層級 [Guid]。用戶端專案參考介面組件 (Embed Interop Types = true) → 編譯器將介面中繼資料嵌入用戶端組件 → 執行時透過嵌入的類型資訊與當前可用的執行時組件繫結,無需重新編譯即可適應新版本。