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
Jon Skeet [C# MVP] - 27 Mar 2008 22:05 GMT
> I'm used to my class returning records -- let's say employee records -- in a
> DataSet (ok, so DataTable within a DataSet technically).
[quoted text clipped - 8 lines]
>
> 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

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Mick Wilson - 27 Mar 2008 22:15 GMT
> I'm used to my class returning records -- let's say employee records -- in a
> DataSet (ok, so DataTable within a DataSet technically).
[quoted text clipped - 11 lines]
> Thanks,
> Ron
Is the compiler giving you the error? If so, I think your issue is
that the IEnumerable interface defines only the method for the
Enumerator. If you want the other methods back to manipulate the
object, you should probably cast it to the run-time type you're
expecting to work with (or modify the return type of the class).
Thanks,
Mick