Inheritance of Custom Attributes on Abstract Properties

Instead of calling PropertyInfo.GetCustomAttributes(…), you have to call the static method System.Attribute.GetCustomAttributes(pi,…), as in: PropertyInfo info = GetType().GetProperties(); // this gets only the attributes in the derived class and ignores the ‘true’ parameter object[] DerivedAttributes = info.GetCustomAttributes(typeof(MyAttribute),true); // this gets all of the attributes up the heirarchy object[] InheritedAttributes = System.Attribute.GetCustomAttributes(info,typeof(MyAttribute),true);

C# Interface Inheritance to Abstract class

Here: public class ConreteFunctionality:AbstractFunctionality { public void Method() { Console.WriteLine(“Concrete stuff” + “\n”); } } … you’re not overriding the existing method. You’re creating a new method which hides the existing one. (You should get a warning, too, suggesting the use of the new modifier if you really want this behaviour.) The interface was implemented … Read more

Pure virtual methods in C#?

My guess is that whoever told you to write a “pure virtual” method was a C++ programmer rather than a C# programmer… but the equivalent is an abstract method: public abstract void TurnRight(); That forces concrete subclasses to override TurnRight with a real implementation.

What’s the difference between an abstract class and an interface? [duplicate]

There are technical differences between Abstract Classes and Interfaces, that being an Abstract Class can contain implementation of methods, fields, constructors, etc, while an Interface only contains method and property prototypes. A class can implement multiple interfaces, but it can only inherit one class (abstract or otherwise). However, in my opinion, the most important difference … Read more

call to pure virtual function from base class constructor

There are many articles that explain why you should never call virtual functions in constructor and destructor in C++. Take a look here and here for details what happens behind the scene during such calls. In short, objects are constructed from the base up to the derived. So when you try to call a virtual … Read more

Can’t instantiate abstract class with abstract methods

Your issue comes because you have defined the abstract methods in your base abstract class with __ (double underscore) prepended. This causes python to do name mangling at the time of definition of the classes. The names of the function change from __json_builder to _Base__json_builder or __xml_builder to _Base__xml_builder . And this is the name … Read more