C# 如何检索放射组的选定值

C# 如何检索放射组的选定值,c#,xamarin,xamarin.ios,monotouch.dialog,C#,Xamarin,Xamarin.ios,Monotouch.dialog,考虑到下面的代码(Xamarin-c#),您将如何检索RadioGroup的选定值 var root = new RootElement ("Meals") { new Section ("Dinner"){ new RootElement ("Dessert", new RadioGroup ("dessert", 2)) { new Section () { new RadioElement ("Ice Crea

考虑到下面的代码(Xamarin-c#),您将如何检索RadioGroup的选定值

var root = new RootElement ("Meals") {
    new Section ("Dinner"){
        new RootElement ("Dessert", new RadioGroup ("dessert", 2)) {
            new Section () {
                new RadioElement ("Ice Cream", "dessert"),
                new RadioElement ("Milkshake", "dessert"),
                new RadioElement ("Chocolate Cake", "dessert")
            }
        }
     }
}

谢谢

我停止编写代码有一段时间了,当我回来时,我意识到该怎么做:

    private void Save()
    {
        List<Element> elementList = new List<Element> ();
        elementList = Root [1].Elements;
        foreach (Element element in elementList) {
            RootElement radioElement = (RootElement)element;
            user.Title = radioElement[0].Elements[radioElement.RadioSelected].Caption;
        }
        user.Save ();
    }
private void Save()
{
List elementList=新列表();
elementList=Root[1]。元素;
foreach(元素列表中的元素){
RootElement radioElement=(RootElement)元素;
user.Title=radioElement[0]。元素[radioElement.RadioSelected]。标题;
}
Save();
}

我停止了一段时间的编码,当我回来时,我意识到该如何做:

    private void Save()
    {
        List<Element> elementList = new List<Element> ();
        elementList = Root [1].Elements;
        foreach (Element element in elementList) {
            RootElement radioElement = (RootElement)element;
            user.Title = radioElement[0].Elements[radioElement.RadioSelected].Caption;
        }
        user.Save ();
    }
private void Save()
{
List elementList=新列表();
elementList=Root[1]。元素;
foreach(元素列表中的元素){
RootElement radioElement=(RootElement)元素;
user.Title=radioElement[0]。元素[radioElement.RadioSelected]。标题;
}
Save();
}

您也可以将它们保存在类变量中(而不是在对象初始值设定项中新建),并在尝试保存时直接访问它们。是的,这很有意义。非常感谢。您还可以将它们保存在类变量中(而不是在对象初始值设定项中新建),并在尝试保存时直接访问它们。是的,这是有意义的。非常感谢。