Visual Studio compiler messages

Almost every programming languages knows the concept of string arrays. You have them in C, C++, Pascal, Delphi, you name it. (Do you miss Basic’s READ / DATA statement?).

Not so C#. Trying a declaration like

protected const string[] rgsExt = new string[] { ".pdf", ".html" };

brings up the meaningful compiler error message

A const of reference type other than string can only be
initialized with null

As you would expect, pressing F1 brings up a help page which describes what you did wrong. Or does it?

If you double-click the message, then hit F1, you get the topic “new (C# Reference) “.

If the cursor is positioned somewhere on the wiggly phrase that causes the error, and press F1, you are directed to the help topic of either “new” or “string”.

If you press F1 somewhere on or near that line, you get nearly random help messages.

If you stay in the error message window, and hit F1, the help displays the topic “Compiler Error CS0029”

Error Message
Cannot implicitly convert type 'type' to 'type'

which is totally irrelevant to the original error message.

Why do I need to google for “c# const string array” only to find out that the only way to do it is using the readonly modifier, instead of const?

Seems I am not the only one who thinks MSDN help is useless. 355.000 hits as of today.


One Response to Visual Studio compiler messages

  1. techsoda says:

    I use to do most of my technical searches. Also here is my post on readonly vs constants

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: