简体   繁体   中英

C# dynamic as type argument

In the book C# in Depth, section 4.1.4, Jon Skeet calls out two rules for using dynamic:

A type can't specify that it implements an interface using dynamic anywhere in a type argument.

So far so good.

But right afterwards he states:

A class can specify a base class that uses dynamic in a type argument, even as part of an interface type argument.

So, deriving from a generic class using dynamic as the type argument is fine. Also good. But what does it mean that you can use it "even as part of an interface type argument"? What is an "interface type argument"? Isn't that ISomeInterface<TInterfaceTypeArgument> ? Isn't that exactly what's not possible as by the sentence above?

What am I understanding wrong?

Ah, I think, I got it:

class Derived : Base<ISomeInterface<dynamic>>

is also allowed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM