With all the knowledge I possess at this very moment I cannot decide which shall I use for my use case.
This is now example with struct.
The first class looks like this:
class Owner
{
public A[] Kids;
public Owner(int count)
{
Kids = new A [count];
// If I would use classes I would need to create new class for each item, right?
// It would look like below and my worries are memory impacts because of new A()
// for(int i = 0; i < count; Kids[i++] = new A());
}
}
The second class looks like this:
class Node
{
private Owner o;
private int num;
private A[] kids;
public Node(Owner o, int num)
{
this.o = o;
this.num = num;
}
public A[] Kids
{
get
{
this.kids = o.Kids[num].NextList;
return this.kids;
}
}
}
The type A looks like this
<struct or class> A
{
public int Value;
public A[] NextList;
}
The question is now when using structs would the access run faster than when using classes?
Would I get memory overhead when using classes since I would need to initalize each class.
Would I need to take care of killing references when using classes?
Which would you use guys in this case?
I apologize in case this is a duplicate or if i did something wrong. Please tell me what I did wrong before downgrading the question. I am still new to this forum.