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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:34:31+00:00 2026-05-18T01:34:31+00:00

In the below code, I would like to use the code in static load

  • 0

In the below code, I would like to use the code in static load method to refresh the object… but how would I reset the current object with new object ? Is copying field by field is the only way ?

class WIP
{
    //  <Snipped> Various other properties...
    public Boolean Refresh()
    {
        //  Need to change the current object with the updated object
        this = WIP.Load(this.ObjectID);  // Says this is readonly...
        return true;
    }

    public static WIP Load(long ObjectID)
    {
        //  This static method fetches the data from DB and returns the object.
    }
}

Edit : I just got this idea after posting the question… Are there any traps in this ?

class WIP
{
    //  <Snipped> Various other properties... 
    public Boolean Refresh()
    {
        //  This method fetches the data from DB and updates the object. 
    }

    public static WIP Load(long ObjectID)
    {
        WIP newObject = new WIP();
        newObject.ObjectID = ObjectID;
        newObject.Refresh();
        return newObject;
    }
} 
  • 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-05-18T01:34:32+00:00Added an answer on May 18, 2026 at 1:34 am

    No, you can’t. The closest you can come is basically to copy every member – which isn’t going to work if some are read-only, of course.

    Either you’re trying to make your object immutable – in which case it shouldn’t change under the feet of code which already has a reference to your object – or you’re not, in which case you just need to make it fully mutable (ideally in some atomic fashion if there are multiple threads involved).

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

Sidebar

Related Questions

I would like to know how to modify the below code to strip =20
I would like to use factory classes and methods to generate GUI components, but
How would I achieve the pseudo-code below in JavaScript? I want to include the
I have a class that only has static members. I would like to register
When running the below code a type is never returned, despite there being a
In the below code snippet can i replace char * to const char *
I have the below code in stdafx.h. using namespace std; typedef struct { DWORD
In the below code sample, what does {0:X2} mean? This is from the reflection
In the below code, the ListBox gets filled with the names of the colors
When retrieving objects from an NSMutableArray in cocoa-touch is the below code ok? Should

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.