mardi 4 avril 2017

C# Initialize Object Pattern to avoid call of virtual method

i have a question concerning a pattern for initialisation of new objects. Currently my constructors includes some virtual methods which leads to the warning for virtual method calls in a constructor. For example to subscribe to an event.

I was wondering if there is a common pattern to solve this problem. As far as i know some programmers are using a separate method to initialize the new object. Imho this pattern could bring some issues. You always have to check if this object is initialized for example during setting a property if initialization is required for this property.

Any Ideas or other recommendations?

Aucun commentaire:

Enregistrer un commentaire