ref class Item { /* ... */ };
void ProcessCollection(ICollection^ c);
int main()
{
List^ myList = gcnew List;
Queue^ myQueue = gcnew Queue;
ProcessCollection(myList);
ProcessCollection(myQueue);
}
void ProcessCollection(ICollection^ c)
{
Item^ x = gcnew Item();
/*1*/ c->Put(x);
/*2*/ x = static_cast<Item^>(c->Get());
}