I have a class in C#, let's say:
public class COUNTRY
{
COUNTRY * neighbor;
string countryName;
}
C# is complaining that it can not point to itself (error code: CS0208)
This is allowed in C. For example:
typedef struct country
{
struct country *neighbor;
char[50] countryName;
} COUNTRY;
COUNTRY unitedNation[]
{
{COUNTRY a, "US"},
{COUNTRY b, "ABC"},
{COUNTRY c, "XYZ"},
{0,""}
}
COUNTRY a
{
{0, "Mexico"},
}
COUNTRY b
{
{0,"Findland"}
}
COUNTRY c
{
{0, "Australia"}
}
The structure defines a country with its neighbors.
unitedNation is a collection of many countries.
To simplify the issue, let's assume, a country can only have 1 or no neighbor. The variable of type COUNTRY could be easily initiated in C through declaration.
Does C# have similar ability?