CSharp

ジェネリッククラスの定義

class MyGenericClass1<T> where T : struct {
 // 制約:Tは構造体
}
class MyGenericClass2<T> where T : class {
 // 制約:Tはクラス
}
class MyGenericClass3<T> where T : new() {
 // 制約:Tはインスタンス化可能
}
class MyGenericClass4<T> where T : MyOtherClass {
 // 制約:TはMyOtherClassクラスを継承
}
class MyGenericClass5<T> where T : IMyInterface {
 // 制約:TはIMyInterfaceインターフェイスを実装
}
class MyGenericClass6<T, U> where T : U {
 // 制約:Tは別の型パラメータUを継承
}
class MyGenericClass7<T, F> : IDisposable
       where T : MyOtherClass<F>, IDisposable, new()
       where F : class
{
 // 制約:T,Fは別々のクラス
}
//////////////////////////////////////////////////
class MyOtherClass {
 // あるクラス
}
interface IMyInterface {
 // あるインターフェイス
}


セシウム137を97.7%吸着

コメント:



(画像の文字列を入力して下さい)

トップ   編集 凍結解除 差分 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2019/12/02 (月) 12:45:43 (1627d)

G|Cg|C@Amazon Yahoo yV

z[y[W yVoC[UNLIMITȂ1~] COiq COsیI