tags:

views:

32

answers:

2
private void DisplayFiles()
{
    lstPhotos.Items.AddRange(files);
}

files is a List This gives this error:

cannot convert from 'System.Collections.Generic.List' to 'object[]'

Which makes sense. What should I do?

+2  A: 

Try this instead:

private void DisplayFiles()
{
    lstPhotos.Items.AddRange(files.ToArray<object>);
} 
APShredder
Thanks, 9 minutes and I accept this answer.
Sergio Tapia
+1  A: 
private void DisplayFiles()
{
    lstPhotos.Items.AddRange(files.ToArray());
}

That should work. You could also bind the list to the listbox which is the preferred way of doing it in WPF and Windows Forms.

lstPhotos.DataSource = files; // Windows Forms
lstPhotos.ItemsSource = files; // WPF
Josh Einstein