Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6022273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:50:05+00:00 2026-05-23T03:50:05+00:00

I have the following problem. This is a simple example of some classes I

  • 0

I have the following problem. This is a simple example of some classes I have (each have dependencies on other classes).

public Class1()
{
  public Class1(Class2 class2)
 {

 }
}

public Class2()
{
  public Class2(Class3 class3)
 {

 }
}

public Class3()
{
 public Class1 class1;
 public Class3(Class1 class1)
 {
     this.class1 = class1;
 }
}

I then have the following code initialising the objects.

Class1 class1 = null;
Class2 class2 = null;
Class3 class3 = null;

class3 = new Class3(class1);
class2 = new Class2(class3);
class1 = new Class1(class2);

Assert.IsNotNull(class3.class1)

The problem I have is that the assert is always null, even though class1 has been initalized. One condition I do have is that I only want there to be one instance of each class created.

Can anybody advise the best way to make sure the assert passes.

  • 1 1 Answer
  • 4 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:50:06+00:00Added an answer on May 23, 2026 at 3:50 am

    class1 is not initialized to its object when class3 is created, thus class3’s instance of it is null.

    The proper way to make this test pass is:

    Class1 class1 = null;
    Class2 class2 = null;
    Class3 class3 = null;
    
    class1 = new Class1();
    class3 = new Class3(class1);
    class2 = new Class2(class3);
    class1.Class3 = class3;
    
    Assert.IsNotNull(class3.class1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on the following problem from this book . A certain
I have the following problem. I am making this website you can see in
Hello i have the following problem, I record a video using red5 like this:
This is a code review question more then anything. I have the following problem:
Never ran into this problem with jQuery before. I have the following: $(document).ready(function() {
Never thought I'd have this problem :) The following snippet of code works in
I have the following problem: Suppose I have some basic counter class Counter .
I have the following classes: [DataContract] [KnownType(typeof(SpecifiedItemCollection))] public class ItemCollection<T> : IEnumerable where T
I have a following problems with eclipse, when I installed ClearCase plugin from this
I have problems with the following bit of javascript/jquery code: this.droppable = function(){ $('.imageWindow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.