How to copy ICollection object contents to List ?
-
I have method to which object of Type ICollection is getting passed. I want to create an object of List<> (Generic List) , with object of ICollection. Is that possible? kumar
You can use the ICollection interface to iterate over the collection, and then put the items into a List, or whatever.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "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 )
-
You can use the ICollection interface to iterate over the collection, and then put the items into a List, or whatever.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "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 )
thanks, but i don't want to iterate, is that direct way, like while creating ArrayList object we can directly pass ICollection object to the constructor of ArrayList so that the contents of ICollection get copied to Arraylist object, is something like possible with generic List (List<>) object?
-
thanks, but i don't want to iterate, is that direct way, like while creating ArrayList object we can directly pass ICollection object to the constructor of ArrayList so that the contents of ICollection get copied to Arraylist object, is something like possible with generic List (List<>) object?
I don't think so, not if the ICollection is not templated. because, the difference is, an ArrayList and an ICollection both knew they were just holding objects.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "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 don't think so, not if the ICollection is not templated. because, the difference is, an ArrayList and an ICollection both knew they were just holding objects.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "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 )