> HI Everyone and especially Pete,
>
> I apologize for dragging everyone through my learning spams.
That's okay. Sometimes learning is a struggle. :)
> The
> answer was in that url I mentioned earlier. I would have thought that
> I could get the properties of a class, generic or not by some
> interation method. But this works. And Pete was right. My use of a
> generic class here added no value over the old collection method.
Well, there _could_ be value, depending on the situation.
In your example, you've made the class generic. Assuming there's a
good reason for making the whole class generic, and assuming you'll
always be passing a List<T> to the method, then you've simplified the
call by one parameter. So that's something. :)
Also note that methods can be generic too. So if that's the only thing
in the class that actually relies on the T parameter, you could instead
make the class a regular class with a generic method defined like this:
public DataTable ReturnObjectCollectionAsTable<T>(List<T> GenList)
{
...
}
And finally, I didn't notice anything in the method that actually uses
an instance member of the class, so assuming it's otherwise
appropriate, you could in fact make the method a static method as well,
allowing you to call it any time, without instantiating an instance of
the class or requiring a pre-instantiated instance of the class.
> I
> learned something and hopefully no one got a headache. I can use this
> for any business object class type but I could have used regular
> collections for that.
I have a headache, but it's not because of anything in this newsgroup.
:) Anyway, as you say, you've learned something and I suspect that the
difficulty in making the breakthrough will translate to you recalling
the specifics that much better. :)
Have fun! :)
Pete