0

I am working with a library that requires an array in the following format:

  var AxisInfo = new object[]
  {
    new {axis = new {_axisName = "Weight", _axisType = "Continuous", _axisId = "115"}},
    new
    {
      MyCustomAttribute1 = "My First Attribute Value",
      MyCustomAttribute2 = "My Second Attribute Value"
    }
  };

First of all, what sort of array is this? Some kind of nested or jagged array? I haven't seen an array defined like this before. Secondly, if you look at the array {MyCustomAttribute1 = "My First Attribute Value", MyCustomAttribute2 = "My Second Attribute Value"}, what are MyCustomAttribute1 and MyCustomAttribute2 known as? Are they array properties or do they have another name?

Finally, is there a way to dynamically create an array like {MyCustomAttribute1 = "My First Attribute Value", MyCustomAttribute2 = "My Second Attribute Value"}? By that I mean, if I have a dictionary as follows:

Dictionary<string, string> Attributes = new Dictionary<string, string>();
Attributes.Add("MyCustomAttribute1", "My First Attribute Value");
Attributes.Add("MyCustomAttribute2", "My Second Attribute Value");
Attributes.Add("MyCustomAttribute3", "My Third Attribute Value");
Attributes.Add("MyCustomAttribute4", "My Fourth Attribute Value");
Attributes.Add("MyCustomAttribute5", "My Fifth Attribute Value");

could I convert this into an array like this:

{MyCustomAttribute1 = "My First Attribute Value", MyCustomAttribute2 = "My Second Attribute Value", MyCustomAttribute3 = "My Third Attribute Value",MyCustomAttribute4 = "My Fourth Attribute Value",MyCustomAttribute5 = "My Fifth Attribute Value"}
Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
Palps
  • 568
  • 9
  • 20

0 Answers0