It's different on a per language basis, but in most languages:
Braces {} are generally for object notation and grouping.
they define an object. Such as when you use them to define a class, enum, stuct ect.
Or for enclosing a memeber or code group, such as a method or property.
In your example:
string[] Meats = { "Roast Beef", "Salami", "Turkey", "Ham", "Pastrani" };
This is an object notation. It's not short hand specifically for creating an array, you can actually create any object this way.
public class myobject
{
public string Title {get; set;}
public bool isInit {get; set;}
}
//create shorthand:
myobject mo = new myobject(){Title="mytitle", isInit=false};
Brackets [] are indexers
when an object can be indexed, the [] supply a selector for the index.
When decaling a type, adding [] to the end is stating that you want an indexable array.
The only other time you will see brackets in C# is for flags. Sometimes when you define a class or interface you will want to flag the members for serialiaztion such as if you wanted to ignore a property in a class you would use the [XmlIgnore()] flag.
public class myobject
{
[XmlIgnore()]
public bool ShipmentSpecified
{ get; set; }
}
Parentheses () are used in math, casting, grouping, and calling.
Mainly () are for parameters. They are used to denote a situation where a parameter could be passed or recieved. This is most …