Intercept call to property get method in C#
- by michajas
Let's assume that we have this class:
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
Now, is it possible in C# to intercept call to property get method, run some other method and return result of that method instead of property value? I'd like to be able to do some additional logic behind the scene.
The downside is that this class can't be changed (on C# level). Maybe some IL ?