I regret my Engilsh. I have a class like this:
public class MainClass
{
public string message { get; set; }
public MainClass forward { get; set; }
}
And I have Main funcion, where I initialize the class and fill in the data (in a real project, I have data in JSON format, where the class can be built in an infinite number of times) of the class:
static void Main(string[] args)
{
MainClass clasClass = new MainClass()
{
message = "Test1",
forward = new MainClass()
{
message = "Test1_1",
forward = new MainClass()
{
message = "Test1_1_1",
forward = new MainClass()
{
message = "Test1_1_1_1",
forward = new MainClass()
}
}
}
};
}
How to get the number of nested class names without knowing their number?
source
share