IDE Woes

So, the following line crashes the VS.NET 2007 complier/IDE:

const string[] attributesToReturn = null;

I'm not reassigning the string array, so this didn't make any sense to me until I dug a little farther. Arrays are objects in C#, and objects are created at runtime. const entries in C# need to be resolved at compile time. There's another modifier, readonly, that works similarly to const, but values may be set at runtime and then not further changed.

Now, I still don't know why the complier and IDE failed entirely, but at least I know why the code was wrong.

No comments: