2
Hello I wonder if there is a way to find out if the value of a property has changed.
Example
public partial class MinhaClasseExemplo
{
public int Id { get; set; }
public String Nome { get; set; }
public String Telefone { get; set; }
}
var teste = new MinhaClasseExemplo();
teste.Nome = "Hiago";
teste.Telefone = null;
In the above example I define the class and instate the object, after which I assign the value to the Nome
and to the Telefone
(yes I put the null
on purpose). I would like to know via Reflection
which ones setters
were called, in that case the Nome
and Telefone
and not the Id
. There’s a way to do that with C#
? I need something like this to make my routine generic.
Thank you.
Just as curiosity and informative, there is an interface called
INotifyPropertyChanged
, which is used to monitor changes in the state of an object and update clients (clients), linked (Binding clients) with the object, that a property has been changed.– Gabriel Heming
@Gabrielheming top guy!! That already helped, what is boring is having to keep creating the private properties =/
– Hiago Souza
@Gabrielheming guy thank you so much!!! Help and a lot, want to put as an answer? So I mark it as correct. Will help me a lot!
– Hiago Souza
I ended up deleting the comment, but there’s the link: https://stackoverflow.com/a/1316417/1628790 . I was in doubt about the . NET core. Implement it and see the result.
– Gabriel Heming