私はこの状況にあります:
public class FOO<T> where T : IBar
{
private T _xxx;
public Y(T xxx)
{
if (xxx == null) throw new ArgumentNullException("xxx");
_xxx = xxx;
}
}
public interface IBar
{
string XString { get; }
}
コンストラクターで、をチェックT
していnull
ます。コンパイラは、構造体によって実装される可能null
性がある値型である可能性があるものをチェックしていることを正しく警告します。IBar
T
参照型になるように制約するにはどうすればよいですか?