Windows Phone Developers

Sunday, August 24, 2008

Bad array declarator: To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the

An array was declared incorrectly. Be aware that the syntax for a fixed size buffer is different from that of an array. - Compiler Error CS0650

Wrong Declaration

char CopiedString[];

char[] CopiedString;

Correct Declaration

char[] CopiedString = new char[3];

Bad array declarator: To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type.

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

3 comments:

  1. Thanks for your post, at school we program in java und at work I program in c#, so I always get confused with declaring arrays ;)

    ReplyDelete
  2. //Why is this in error?

    string[,] cmdArr = new string[2,3] {
    {"quit | exit", "Ends the program."},
    {"list", "Prints out the current text list."},
    {"help", "Prints the list of possible commands."}
    };

    ReplyDelete
  3. [WebMethod]
    public Tool[] getToolList(string s)
    {

    Tool[] a = new Tool[2];

    Tool a[0]=new Tool();
    // the above throws an error. WHY?

    a[0].ToolID = "1";
    a[0].Description = "TOOL1";

    a[1].ToolID = "2";
    a[1].Description = "TOOL2";

    // Console.WriteLine(a[0]);

    return a;
    }

    public class Tool
    {
    public string ToolID;
    public string Description;
    }

    ReplyDelete