hi all,
Am trying to create a structure with members ,creating an arraylist to get input from textbox so that it can bind in listbox. I am not geting the desired thind.Code attached .
Kindly help
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public struct MyStruct
{
public string name;
public string data;
}
private void button1_Click(object sender, EventArgs e)
{
ArrayList arr = new ArrayList();
arr.Add(textBox2.Text);
arr.Add(textBox1.Text);
MyStruct[] array = new MyStruct [arr.Count];
arr.CopyTo(array);
for (int i = 0; i < arr.Count; i++)
{
listBox1.Items.Add(array[i].name);
listBox1.Items.Add(array[i].data);
}
}
}
}
Am geting an error in copying arraylist to array then accessing it.
Kindly some one help