Determine Collection Type at run time
-
I am trying to make a generic form that has a datagridview on it. I want to be able to send in multiple types of collections, the type will be determined at runtime, to the form to be bound to the datagridview. Im guessing I need to use generics for this, but Im not sure how to do it. thanks :)
-
I am trying to make a generic form that has a datagridview on it. I want to be able to send in multiple types of collections, the type will be determined at runtime, to the form to be bound to the datagridview. Im guessing I need to use generics for this, but Im not sure how to do it. thanks :)
No, you probably want to use IEnumerable, or some other interface that is common to collection classes.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
No, you probably want to use IEnumerable, or some other interface that is common to collection classes.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
I tried using IEnumerable but I could not convert List<> to use it. Am I doing something wrong?
IEnumeration is an interface that your collection has to implement. There are plenty of samples on implementing IEnumerable. :) Once you've done that, you can simply use foreach to iterate over the collection.
Cheers, Vıkram.
After all is said and done, much is said and little is done.