user2953119
user2953119

Reputation:

Anonymous subclass

How to create an instance of an anonymous subclass in C#? Let I have a base class Bclass and I want to create an instance of sublclass with an additional method and a property? How is it possible to do?

Upvotes: 2

Views: 482

Answers (1)

Christoph Fink
Christoph Fink

Reputation: 23103

Anonymous classes (aka anonymous types) can not extend another class or implement an interface.

If you need inheritance or to implement an interface you need to create a named class.

Upvotes: 5

Related Questions