Robert Venables
Robert Venables

Reputation: 5981

Interface Type Constructor

In chapter eight (p189) of "CLR Via C#", Jeffrey Richter states that:

"A Type constructor can be applied to interfaces (although C# doesn't allow this)"

I've done a little bit of research and I can't seem to find why an interface would ever need a type constructor, in any language. This seems like something that you would explicitly disallow in the CLR.

When would this ever be needed, and why is it possible?

Upvotes: 5

Views: 361

Answers (2)

mfawzymkh
mfawzymkh

Reputation: 4108

Think of it in situations where you want to treat the interface as an abstract class. Although C# doesn't support that.

Upvotes: 0

LBushkin
LBushkin

Reputation: 131806

You may be interested in reading this question and some of its answers on SO.

It basically covers how the C# compiler instantiates COM objects based on interfaces. It's not necessarily the same situation that Richter discusses, but its an interesting case of instantiating interfaces.

Upvotes: 3

Related Questions