Noel ST Noel ST - 6 months ago 39
C# Question

C# Class array?

The following seems to be a class array?


It seems that there are several other fields associated with Chemical, such as Cost, Quantity,
(Chemical.Cost etc).

I was wondering what this type of variable is called? A class array? I've been searching online about arrays and can't seem to find any documentation on this.

And secondly, how do I declare such a variable?


Variable would look something like that

public class Chemical{
 public ChemicalName[] ChemicalNames = new ChemicalName[5];


So you can invoke it like that

Chemical c = new Chemical();

OR, you can also declare the Array as static so you wont need an intance of the class to get the array e.g.

public class Chemical{
 public static ChemicalName[] ChemicalNames = new ChemicalName[5];


to call a static, simply use class.variable/method name