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

The Archive Base Latest Questions

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

In both Ruby and PHP (and I guess other languages as well) there are

  • 0

In both Ruby and PHP (and I guess other languages as well) there are some utility methods that are called whenever a property is set. ( *instance_variable_set* for Ruby, *__set* for PHP).

So, let’s say I have a C# class like this:

public class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

Now, let’s say that if any property setter from the Person class is called, I want to call another method first, and then continue with the default behaviour of the setter, and the same applies for the property setters.

Is this possible?


Edit:
I want to do this without defining a backing field.

  • 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-22T11:36:01+00:00Added an answer on May 22, 2026 at 11:36 am

    Not generally; a few options though;

    • inherit from ContextBoundObject – which does allow this, but at a performance cost
    • write an explicit property (i.e. with a backing field), and add a utility method call manually
    • look at compile-time weavers, such as PostSharp – generally by spotting an attribute or similar
    • look at runtime code generators, as offered by some DI/IoC tools (and some other “decorator” based tools) – which either decorate or subclass your object to add the extra code
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why do this Ruby object both a to_s and inspect methods that appear to
Given that both Ruby on Rails (RoR) and Grails can run on the JVM
i wonder if there are tutorials that go through the syntax differences for ruby
I keep hearing everything is an object in both Ruby and Python world. Well,
Both Ruby and Python have the ability of calling the debugger from code (
I use both ruby on rails and Java. I really enjoy using migrations when
New to both Ruby and Rails but I'm book educated by now (which apparently
I've heard both MacRuby and Ruby CocoaBridge discussed in relation to iPhone/iPad development in
In Ruby (1.8.X) Why does Object both inherit off Kernel and include it? Wouldn't
I'm new on both this site and ruby on rails! I have a common

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.