Using XML elements

后端 未结 1 1503
感情败类
感情败类 2021-01-29 08:12

I have working code that I\'d simply like to reference parts of multiple times in other area\'s of my program, however my problem seems to be with anonymous types (var)

相关标签:
1条回答
  • 2021-01-29 08:39

    the XML is needing to be referenced in multiple parts of the program,

    But all your variables are local. You need to store something in a Form fiead or property.

    // outside any method:
    private List<string> names = new List<string>();
    
    void myLoadMethod()
    {
        ...
        foreach(var HandlingName in query)
        {
            //string Names = HandlingName.HandlingName;
            Names.Add(HandlingName.HandlingName);
        }  
    }
    
    private void button1_Click(object sender, EventArgs e)
    {
        comboBox1.Items.Add( Names);
    }
    
    0 讨论(0)
提交回复
热议问题