Wednesday, March 1, 2017

Cannot pass 'whatever' as a ref or out argument because it is a 'foreach iteration variable'

You cannot do the ref thing inside a foreach loop in C# and what is more, even if you try to hack around this by just handing in a reference type without the ref keyword, the stuff you set on your object in the method to doctor it up will not "stay around" so to speak back at the end of the foreach loop. Lame! I found a StackOverflow article that kinda suggested that this has to do with the enumerator getting confused. Whatever.

No comments:

Post a Comment