How to make this array + function to work?

前端 未结 1 1445
失恋的感觉
失恋的感觉 2021-01-29 07:18

I need help with my array. I\'m new on C# Winforms.

This is my function where the array is going, I\'m trying to post the array on XML file:

    // -----         


        
相关标签:
1条回答
  • 2021-01-29 07:59

    Change the signature of the method to

    static void XML_Array(Dictionary<string, string> Data_Array)
    

    since it's not a string but a Dictionary.

    As varg and Austin have commented you should consider to rename your variables because it's confusing when an argument is names Data_Array but actually it is a Dictionary what is a completely different type of collection. You probably want to add the Text property of an existing TextBox control, not the string literal(with quotes) "textBox3.Text".

    Data_Array.Add("Name", textBox3.Text); // Alex
    Data_Array.Add("Year", textBox4.Text); // 1988
    

    TextBox3 and TextBox4 are also good candidates for new names.

    0 讨论(0)
提交回复
热议问题