What is the syntax for placing constraints on multiple types? The basic example:
class Animal<SpeciesType> where SpeciesType : Species
I would like to place constraints on both types in the following definition such that SpeciesType
must inherit from Species
and OrderType
must inherit from Order
:
class Animal<SpeciesType, OrderType>
public class Animal<SpeciesType,OrderType>
where SpeciesType : Species
where OrderType : Order
{
}
You should be able to go :
class Animal<SpeciesType, OrderType>
where SpeciesType : Species
where OrderType : Order {
}
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.