2011-01-11 79 views

回答

1

Named and optional arguments在C#4中引入。這些參數允許開發人員編寫更少的方法重載。

它們在處理COM互操作場景時也很有幫助。以下是來自MSDN的示例。

可選參數之前:

excelApp.get_Range("A1", "B4").AutoFormat(myFormat, Type.Missing, 
    Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); 

可選參數後:

excelApp.Range["A1", "B4"].AutoFormat(Format: myFormat); 
相關問題