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];
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//Why is this in error?
ReplyDeletestring[,] cmdArr = new string[2,3] {
{"quit | exit", "Ends the program."},
{"list", "Prints out the current text list."},
{"help", "Prints the list of possible commands."}
};
[WebMethod]
ReplyDeletepublic 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;
}