Noel ST Noel ST - 1 year ago 136
C# Question

C# Class array? - Visual Studio

The following seems to be a class array?


It seems that there are several other fields associated with Chemical, such as Cost, Quantity, SupplierName (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?


Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download