[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

What does mean to instantiate a class object during this same class initialization?

I'm looking at some code that a new class has a line of code instantiating it during its deiniting.  What's the purpose of this?  Is this the class contructor now?  Why does have that named as ParentInterest?  It usually just the same name as the class, isn't it?  I'm confused here.
Thanks.

    public class IInterest
    {
        public Interest ParentInterest { get; set; }
        public long Id { get; set; }
        public string Name { get; set; }
    }
0
lapucca
Asked:
lapucca
1 Solution
 
PlatoConsultantCommented:
 public class IInterest
    {
        public Interest ParentInterest { get; set; }
        public long Id { get; set; }
        public string Name { get; set; }
    }

Interest  and IInterest are seperate classes normally IInterst is used for intereface...

here but if both of them are same classes then the self referential relationship exisits between the two classes that a class contains a refrence to it self...


for example person is a class but person has parents and childs but all of them are persons also hence persons is store refrence to parents and childs which are the same class person...
 
0
 
lapuccaAuthor Commented:
Yes, they're both the same class.  I just had a type there.  
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now