I'm trying to add selected values from list box to array or list and I'm getting a strange error
here is my code
private void button3_Click(object sender, EventArgs e)
        {
            List<string> _AttName = new List<string>();
            for (int _i = 0; _i < listBox1.SelectedItems.Count; _i++)
            {
                if (listBox1.SelectedItem != null)
                {
-> Failes here ->   _AttName.Add(listBox1.SelectedValue.ToString());
                    listBox1.SetSelected(listBox1.SelectedIndex, false);
                }
            }
        }
or
private void button3_Click(object sender, EventArgs e)
        {
            string[] _AttName = new string[listBox1.SelectedItems.Count];
            for (int _i = 0; _i < listBox1.SelectedItems.Count; _i++)
            {
                if (listBox1.SelectedItem != null)
                {
                    _AttName[_i] = listBox1.SelectedValue.ToString();
                    listBox1.SetSelected(listBox1.SelectedIndex, false);
                }
            }
        }
here is the error I get

 
     
    