Reputation: 41
I'm new to c# but struggling with some fairly basic assignments.
This works:
ListViewItem item = new ListViewItem(new[] { "1", "2", "3", "4" });
This Does not:
string[] rrr = new string[4]{ "1", "2", "3", "4" };
ListViewItem item = new ListViewItem(new[] rrr);
My Final goal is:
for (int i=0; i<10; i++)
{
rrr[i] = "SomeText";
}
ListViewItem item = new ListViewItem(new[] rrr);
Apologies for the basic question, I've not been able to find the right keywords to get a solution. I'm more used to VBA which allows me to get away with anything.....
Thanks
Upvotes: 0
Views: 1082
Reputation: 88
Instead of ListViewItem item = new ListViewItem(new[] rrr);
use ListViewItem item = new ListViewItem(rrr);
Upvotes: 2
Reputation: 10211
You should do only this
string[] rrr = new string[4]{ "1", "2", "3", "4" };
ListViewItem item = new ListViewItem(rrr);
so:
for (int i=0; i<10; i++)
{
rrr[i] = "SomeText";
}
ListViewItem item = new ListViewItem(rrr);
Upvotes: 3