I am using initiazling property in a class
and i want to run a validation method after it fully initialized.
i cant use the constructor for obvious reasons. is there a way to do that in some kind of Class initialized event ?
var t = new Foo
{
foo = "";
}
class Foo
{
public string foo {get; set;}
...
public bool validate {get ; set;}
private void validation()
{
if(foo == "")
validate = false;
if ...
}
}
You can add verification logic to properties. Verify if class initialized after property assigned and raise static event if initialization completed. You can get reference to instance by casting event sender to Foo.
Usage: