class Test<T> where : struct {
Test struct, . , Test<MyStruct>,n Test<int> , Test<MyClass> . , . .
, . .
class Gen<T/ V> where V: T {
where , , V, , , , . Gen, . . .
// .
Using System;
class {
//...
}
class : {
//...
}
// V . class Gen<T, V> where V: T {
//...
}
class NakedConstraintDemo { static void Main() {
// ,
// .
GerKA, > = new Gen<A, > ();
// , // -. ..
// Gen<B, > = new Gen<B, >();
}
}
, . Gen Main ().
Gen<A, > = new Gen<A, > ();
, .
// Gen<B, > = new Gen<B, >();
, .
. . class struct, , , . class struct rte . , new (). , .
class Gen<T> where : MyClass, IMylnterface, new() {
//...
, MyClass, IMylnterface .
|
|
, where, .
// where, using System;
// Gen , // where, class Gen<T, V> where T: class
where V: struct {
T obi;
V ob2;
public Gen(T t, V v) { obi = t;
ob2 = v;
}
}
class MultipleConstraintDemo { static void Main() {
// , // string , a int .
Gen<string, int> obj = new Gen<string, int>(nTecTM, 11);
// , // bool .
// Gencbool, int> obj = new Gencbool, int>(true, 11);
}
}