Referencing nested class objects in C#

Viewed 2081

I want to have a class with several nested classes, so that when I create a new parent class, an object of each nested class is created and I can reference the variables within each nested class globally.

Here is my current code:

public class StockChecklist
{
  public class qty1p1 { public string tag = "uniqueval23456"; public string value = ""; public string reference = ""; }
  public class qty1p2 { public string tag = "uniqueval3736"; public string value = ""; public string reference = ""; }

  public class qty2 { public string tag = "uniqueval97357"; public string value = ""; public string reference = ""; }

  public class qty3p1 { public string tag = "uniqueval88356"; public string value = ""; public string reference = ""; }
  public class qty3p2 { public string tag = "uniqueval62346"; public string value = ""; public string reference = ""; }
  public class qty3p3 { public string tag = "uniqueval09876"; public string value = ""; public string reference = ""; }
  public class qty3p4 { public string tag = "uniqueval62156"; public string value = ""; public string reference = ""; }

  public class qty4 { public string tag = "uniqueval25326"; public string value = ""; public string reference = ""; }

}

then I create a new parent object with:

StockChecklist theCurrentList = new StockChecklist();

but how do access the nested objects 'tag', 'value' and 'reference'? I was hoping for something simple like StockChecklist.qty1p1.tag = 'changedval999999999';

Is something like this possible with C#?

3 Answers
Related