I have created an instance of a generic collection in C#, and need to pass one of the members of a struct in this collection by reference to a method. Can I use the generic collection's indexer to select which object's member I want to modify in the method? I seem to get an error ("Cannot modify the return value of 'expression' because it is not a variable") but what I have is similar to this:
Deque<Card> deck_of_cards = new Deque<Card>(); // standard deck of 52 playing cards (structs)
ModifyRank( ref deck_of_cards[4].rank, 8); // Changes the rank (field, int) of the 5th card to 8
I'm converting C++ code which is using std::deque and global methods, and I want to preserve as much as I can in terms of syntax. Does anyone know an elegant solution to this problem?