I have a class like:
class SomeTests {
private Guid[] someGuids = new Guid[] { ... }
public void ThoseGuidsShouldAlwaysBeThere() {
foreach (Guid g in someGuids) { // error appears here
// ...
}
}
}
Semantically, I want someGuids to be const, since they shouldn't be updated, ever, except before recompiling the code. But adding the const keyword generates error CS0168: null is not valid in this context.
Reading the MSDN page for that error, it seems to me that the compiler thinks I'm doing this:
foreach (Guid g in null) {
I don't understand how adding const causes this problem here, and how to solve my semantic problem (list is read-only, not writable) -- keeping it as an array instead of a List is "almost" good enough.