CSharp · Mvc
using System;
using System.ComponentModel.DataAnnotations;
namespace HelloWorldMvcApp
{
public interface IParent<out T>
where T : IChild
{
}
public class Parent<T> : IParent<T>
where T : IChild
{
}
public class Child : IChild
{
}
public interface IChild
{
}
}
@model HelloWorldMvcApp.IParent<HelloWorldMvcApp.IChild>
@{
Layout = null;
}
<div>
works
</div>
using System;
using System.Web.Mvc;
using System.Collections.Generic;
namespace HelloWorldMvcApp
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View(new Parent<Child>());
}
}
}