Can a Custom C# object contain a property of the same type as itself?

后端 未结 8 1292
情深已故
情深已故 2021-02-08 04:03

If I have created the following Employee object (simplified)...

 public class Employee
    {
        public Employee()
        {       
                


        
8条回答
  •  孤街浪徒
    2021-02-08 04:29

    Yes, you can have Employee inside Employee and it will not cause infinite loop, by default Manager property of Employee object will be null.

提交回复
热议问题