How add record to IEnumerable(Of Type) object?

R

Ronald S. Cook

I'm used to my class returning records -- let's say employee records -- in a
DataSet (ok, so DataTable within a DataSet technically).

But now, my class is returning those records as IEnumerable(Of Employee).

While I can still just as easily bind this to a ComboBox, ListBox,
DataGridView, etc., I'm not understanding how to add records to it.

If I try to add a record to, say, the ListBox, it will tell me it can't
because the control is bound.

So, how can I add records to ultimately the IEnumerable(Of Employee) object?

Thanks,
Ron
 
J

Jon Skeet [C# MVP]

Ronald S. Cook said:
I'm used to my class returning records -- let's say employee records -- in a
DataSet (ok, so DataTable within a DataSet technically).

But now, my class is returning those records as IEnumerable(Of Employee).

While I can still just as easily bind this to a ComboBox, ListBox,
DataGridView, etc., I'm not understanding how to add records to it.

If I try to add a record to, say, the ListBox, it will tell me it can't
because the control is bound.

So, how can I add records to ultimately the IEnumerable(Of Employee) object?

You can't, without casting to something which directly supports
addition. Bear in mind that IEnumerable(Of Employee) may be:

1) Implemented by an array of fixed size
2) Read-only
3) Generated dynamically with no concept of addition
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top