I have two classes that make use of auto properties:
class B
{
int a { get; set; }
int b { get; set; }
List <A> listofa { get; set; }
}
class A
{
string c { get; set; }
string d { get; set; }
}
I have deserialized a JSON data source and imported data into the classes. Actually I have 3 class A
objects in my JSON and one B
. So how can I get the values of my objects that were created?
I can get the values of class B properties by testOfB.a
(after the deserialization of course):
B testOfB = JsonConvert.DeserializeObject<RootObject>(testjson);
But how can I get the value of testOfB.listofa
? I am sure I should use a foreach
loop. (I found some examples in some other posts.) But none of it is working for me. I tried something like this:
foreach(object[] in A)
{
???
}
Am I close? Any help would be really appreciated!!
EDIT
Here is the JSON I am deserializing:
{
"a": 12,
"b": 13,
"A": [
{
"c": "test",
"d": "test"
},
{
"c": "test2",
"d": "test2"
},
{
"c": "test3",
"d": "test3"
}
]
}