Intercept call to property get method in C#
Posted
by michajas
on Stack Overflow
See other posts from Stack Overflow
or by michajas
Published on 2010-04-22T14:05:57Z
Indexed on
2010/04/22
14:13 UTC
Read the original article
Hit count: 1080
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 ?
© Stack Overflow or respective owner