Skip to content

This pill demonstrates why it is not a good idea to call abstract or virtual methods from the constructor.

License

Notifications You must be signed in to change notification settings

CSharp-Pills-15mg/Virtual-in-Constructor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual in Constructor

Pill Category

Language (C#)

Description

If we call a virtual method from the constructor, Resharper raises a warning: "Virtual member call in constructor"

Same warning is raised if we call an abstract method and also if we call a virtual or abstract property.

Question

  • Why is it a problem to call virtual or abstract methods or properties from the constructor?

Donations

If you like my work and want to support me, you can buy me a coffee:

ko-fi

About

This pill demonstrates why it is not a good idea to call abstract or virtual methods from the constructor.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Languages