1

我曾经有以下代码:

var root = new RootElement ("Tasks"){
    new Section ("Process Type"){
        new RootElement ("Process", new RadioGroup ("processtype", 0)){
            new Section (){
                guarantor,dependent, volunteer // all these are Elements    
            }
        }
    }       
}; 

现在,我更新Monotouch SDK,Xcode 5等...当我尝试构建项目时,我在以下行出现错误:

new RootElement ("Process", new RadioGroup ("processtype", 0)){

出现以下错误:

HumanResources/HumanPendingRequests.cs(18,18): Error CS0121: The call is ambiguous between the following methods or properties: `MonoTouch.Dialog.Section.Add(MonoTouch.Dialog.Element)' and `MonoTouch.Dialog.Section.Add(System.Collections.Generic.IEnumerable<MonoTouch.Dialog.Element>)' (CS0121)

关于如何修复它以及为什么现在显示该错误的任何线索?

非常感谢。

4

1 回答 1

0

这很奇怪,但很容易解决。强制转换为您想要的类型,c#编译器会找到正确的重载。

var root = new RootElement ("Tasks"){
    new Section ("Process Type"){
        (MonoTouch.Dialog.Element)new RootElement ("Process", new RadioGroup ("processtype", 0)){
            new Section (){
                guarantor,dependent, volunteer // all these are Elements    
            }
        }
    }       
}; 
于 2013-09-25T07:15:44.960 回答