然后,可以将每个指定的值看作是那个类的一个实例,这为您提供了指定的整数集合所无法提供的编译时类型安全。
You can then treat each named value as an instance of that class, providing you with compile-time type safety that a named set of integers can't.
如果客户端代码尝试使用某个约束所不允许的类型来实例化类,则会产生编译时错误。
If client code tries to instantiate your class by using a type that is not allowed by a constraint, the result is a compile-time error.
如果客户端代码尝试使用某个约束所不允许的类型来实例化类,则会产生编译时错误。
If client code tries to instantiate your class by using a type that is not allowed by a constraint, the result is a compile-time error.
应用推荐