I have an object model like this:
p开发者_如何转开发ublic class MyObject{
public int Prop1{get;set;}
public int Prop2{get;set;}
public void MyObjectInit()
{
this.Prop1 = 0;
this.Prop2 = 0;
}
}
How do I create an event handler for MyObject that triggers when the object is initialized and runs MyObjectInit.
Thanks
Why use an event handler. Just use the object constructor.
public void MyObject()
{
MyObjectInit();
}
Or better yet, move the code of MyObjectInit
into the constructor.
精彩评论