Re: Valid constraints.



Kevin Burton wrote:

I have an interface that I am trying to make the generic constraints as
restictive as possible so that the generic types are not what is expected. I
get two errors:

1) Indicates that the contraint type cannot be sealed. How can I get around
this?

Why would you want to? E.g.:

sealed class S {}
class C<T> where T : S {}

.... in this case, C<> can only ever be instantiated with S, since
nothing can derive from S. So what's the point in it being generic then?

2) I get an error that a particular type must come before other constraints.
I am not sure how to order the constraints. I was not even aware from the
documentation that there was a order restriction on the constraints.

Can you show an example?

-- Barry

--
http://barrkel.blogspot.com/
.


Loading