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

  • Home
  • SEARCH
  • 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 8318967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:09:32+00:00 2026-06-08T22:09:32+00:00

I’m trying to call the constructor of class B from class A by passing

  • 0

I’m trying to call the constructor of class B from class A by passing some arguments (args1,args2). I am using something like this:

public class A
{
       private readonly B _b;
       public A()
       {
         _b=new B(TypeA args1,TypeB args2);
       }

...
}

public class B
{

   public B(TypeA  new_args1,TypeB new_args2)
   {
     ...
   }

...
}

But from what I see in debug althougth args1 and args2 have the correct values that I want to send, new_args1 and new_args2 do not change. Is there a specific syntax I have to use to do that?

  • 1 1 Answer
  • 0 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-06-08T22:09:35+00:00Added an answer on June 8, 2026 at 10:09 pm

    I’m not sure why you call the args to the constructor of B “new”. They are the arguments for instantiating that particular object instance.

    Except for the fact that you’re missing a type in the argument declaration, your code looks correct. What exactly is wrong.

    public B(new_args1,new_args2)
    

    is missing the types, e.g.

    public B(int new_args1, int new_args2)
    

    Given the type assumption above

    _b=new B(42, 24);
    

    would cause B to be initialized as

    public B(int new_args1, int new_args2)
    {
        // new_args1 has the value 42
        // new_args2 has the value 24
    }
    

    Assuming you assign those values somewhere in B, e.g.

    public class B 
    {
        public int A1 { get; private set; }
        public int A2 { get; private set; }
        public B(int new_args1, int new_args2)
        {
            // new_args1 has the value 42
            A1 = new_args1;
            // new_args2 has the value 24
            A2 = new_args2;
        }
    }
    

    then

    _b.A1 
    

    would have the value 42, and

    _b.A2
    

    would have the value 24

    after you initialize _b.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to understand how to use SyndicationItem to display feed which is

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.