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 9152495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:03:44+00:00 2026-06-17T12:03:44+00:00

How do I pass one object value to another object that needs the same

  • 0

How do I pass one object value to another object that needs the same value
For example:
If I have

Contact contact = new Contact();
Scheduler scheduler = new Scheduler();

Call a method to get all of the contact information and now I have contact.id available

The scheduler method which is expecting a personId which is the contact.id
Without doing scheduler.personId = contact.id and passing the value to LoadScheduler what is the proper way? thx

private void LoadSchedule(Scheduler scheduler)
{
...
}
  • 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-17T12:03:45+00:00Added an answer on June 17, 2026 at 12:03 pm

    What you are doing isn’t wrong.

    scheduler.personId = contact.id
    LoadSchedule(scheduler);
    

    Or otherwise you would need better argument for your method..

    LoadSchedule(contact.id);
    ...
    private void LoadSchedule(int contactId)
    {
    
    }
    

    But then you wouldn’t have all the fields of Scheduler object to access. But if that matters..

    Or even:

    LoadSchedule(contact);
    ...
    private Scheduler LoadSchedule(Contact contact)
    {
         Scheduler scheduler = new Scheduler { personId = contact.id };
         //load...
         return scheduler;
    }
    

    Or you can have a proper instance method (or extension method) to load schedule from the scheduler object.

    class Scheduler
    {
        public void Load()
        {
    
        }
    }
    

    So now you can call just scheduler.Load() once you have the right instance.. All these aren’t wrong, but depends on which class/layer you need the logics to be in. Without knowing the domain, its hard to say which is the best. Give the job to the right class. To help better, tell us why do you think your approach is wrong in the first place?

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

Sidebar

Related Questions

I know that stuff of calling the new activity and pass the object value
Possible Duplicate: How to pass object from one activity to another in Android I
I'm trying to pass an object from one controller action to another. The object
I'm trying to pass files one by one(I have to dot that since executable
I have use a singleton class that contained just one passed value. I then
I try to pass some value from one page to another but at the
I have a dynamic Class that is a Value Object that is used to
If I have a function in SSJS and I want to pass one firm
If all that you're doing is a simple one-pass iteration (i.e. only hasNext() and
In one method of my Java source code, the same block of code occurs

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.