A
az.anonymous
Im starting to learn C#, and I made a simple stack class. Inside the
stack class I had the following:
class StackElement
{
object info;
StackElement below;
}
Everything works fine cause "below" is just a reference. But, what if
I want to do it with a struct?. Since struct is a value type, how can
I put a reference to itself inside its declaration? I tried something
like:
struct StackElement
{
object info;
ref StackElement below;
}
and
struct StackElement
{
object info;
StackElement *below;
}
but it didn´t work. So how can I do it?
stack class I had the following:
class StackElement
{
object info;
StackElement below;
}
Everything works fine cause "below" is just a reference. But, what if
I want to do it with a struct?. Since struct is a value type, how can
I put a reference to itself inside its declaration? I tried something
like:
struct StackElement
{
object info;
ref StackElement below;
}
and
struct StackElement
{
object info;
StackElement *below;
}
but it didn´t work. So how can I do it?