public class MyClass<T>
{
public T this[int index]
{
get
{
...
}
set
{
...
}
}
public void MyMethod<T>()
{
int middleIndex = ...;
T value = this[middleIndex ];
...
}
}
MyMethod() 内のステートメントのため、コードはコンパイルされません。インデクサーを呼び出す別の方法はありますか?
編集:変更された MyMethod()
Edit2:コンパイルエラー
Error 6 Cannot implicitly convert type 'T [C:\MyClass.cs]' to 'T [C:\MyClass.cs]'
ありがとう。