2008-11-26 80 views

回答

3

不 - 您可以使用任何類型。

例如,XAttribute有一系列定義的轉換中,使各種轉換簡單:

XAttribute attrib = new XAttribute("Foo", "12345"); 
    int i = (int)attrib; 
    string s = (string)attrib; 

另一個有用的例子是喬恩的NonNullable<T> - 這是旨在與類整齊地工作,而不允許空值。轉換運算符使其易於使用。

+0

強制性的「John Skeet」示例: - / – 2008-11-26 11:37:27

相關問題