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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:36:46+00:00 2026-05-22T18:36:46+00:00

Is there anyway to create a dynamically retrievable method which somehow monitors an object’s

  • 0

Is there anyway to create a dynamically retrievable method which somehow monitors an object’s state, yet only has to be called once and will update its result once the state of the object it observes has been modified or changed in some way which wasn’t equal to the state it was at before at the time the method was called.

I have a script here to illustrate my point:

bool isNull = false;

    Object obj = new Object();

    isNull = (bool)obj.ExtNull();

    string reply = TestMethodA(isNull);

    Console.WriteLine("Is object null? Answer: {0}. State of isNull: {1}", reply, isNull);

    obj = null;

    Console.WriteLine("\n\nNulling object... ");
    Console.WriteLine("\n\nNew answer: ");
    Console.WriteLine("\n\nIs object null? Answer: {0}. State of isNull: {1}", reply, isNull);

    Console.Read();
}

public static string TestMethodA(bool isNull)
{
    string str;

    if (isNull)
        str = "yes";
    else
        str = "no";

    return str;

}

As we can see, an object calls an extension method casted as a bool, which meets the method’s return type. This statement is then assigned to the bool isNull variable.

A string is then called, and assigned TestMethodA, which passes isNull as its argument. Once isNull is received in the method’s parameter it analyzes whether or not the boolean is true or false. If it’s true (meaning that the object is null), the string variable called within the method takes “yes” for its value. Likewise, if not, it will take “no.”

The string is then returned, and passed back to the method. Both the string and the boolean are posted in the Console.WriteLine method.

After this happens, the obj reference variable assigns itself null, losing its once had reference.

The WriteLine statement then posts the same statement it had before, analyzing the boolean and the state of the object. Of course, despite the fact that the object’s state is now null,

So, since C# doesn’t really have pointers (a real shame, really, now that I think about it) without unsafe code, is there any way to achieve this dynamically?

  • 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-22T18:36:46+00:00Added an answer on May 22, 2026 at 6:36 pm

    It’s expensive, performance wise, and it’s not completely real time, but you may be able to accomplish what you want here using Reactive Extensions.

    Check out the examples here:

    http://rxwiki.wikidot.com/101samples#toc1

    Specifically, you’d be interested in creating an Observable.Sample or an Observable.Interval.

    Aside from that, you could go the proxy generation route…but that involves more control over the actual types you want to observe. If you are in control of the type definition, you could declare all your properties as virtual and create instances of your type using dynamic proxies (Castle Windsor/DynamicProxy is one tool to do this, though there are others). You could automatically make your type implement INotifyPropertyChanged

    http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-castledynamicproxy/

    and simply bind an event handler to watch the PropertyChanged event.

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

Sidebar

Related Questions

Is there anyway I can create a not in clause like I would have
Is there any way to create C# 3.0 anonymous object via Reflection at runtime
Is there any way in JavaScript to create a "weak reference" to another object?
Is there anyway I can zip dynamically generated content, such as a freshly rendered
Is there any way to create a virtual drive in (My) Computer and manipulate
Is there any way to create the query parameters for doing a GET request
Is there any way to manually create fold points in code in Eclipse? I
Is there any way that I can programmatically create (and I guess access) hidden
If I create an application on my Mac, is there any way I can
Is there anyway to have a sort of virtual static member in C++? For

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.