'How DbCommand.CreateParameter() instantiate an abstract class?

In ado.net DbParameter is an abstract class and hence can not be instantiated but then how DbCommand.CreateParameter() instantiate the same?



Solution 1:[1]

Because DbCommand is abstract, a caller will only ever access the overridden and non-abstract CreateParameter of a type derived from DbCommand.

The documentation is explaining the expected behavior of CreateParameter to both callers who are using the DbCommand and implementors who are writing a specific override.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Scorpion