using System;
using System.Collections .Generic ;
interface IEntity
{
string Name { get; set; }
}
class FooEntity : IEntity
{
public string Name { get; set; }
public FooEntity( )
{
Name = "foo" ;
}
}
interface ILetter< T> where T: IEntity
{
string EntityMetadata { get; set; }
List< T> GetRecords( ) ;
}
abstract class AbstractLetter< T> : ILetter< T> where T: IEntity
{
public abstract string EntityMetadata { get; set; }
public abstract List< T> GetRecords( ) ;
}
class JobLetter< T> : AbstractLetter< T> where T : IEntity, new( )
{
public override string EntityMetadata { get; set; }
public override List< T> GetRecords( ) { return null ; }
public JobLetter( )
{
var entity = new T( ) ;
EntityMetadata = entity.Name ;
}
}
public class Test
{
static List< T< K>> CreateLetterList< T, K> ( ) where T : AbstractLetter< K>, new( ) where K : IEntity
{
return new List< T< K>> { new T< K> ( ) , } ;
}
public static void Main( )
{
var jobLetterList = CreateLetterList< JobLetter, FooEntity> ( ) ;
foreach ( var letter in jobLetterList)
{
Console.WriteLine ( letter.EntityMetadata ) ;
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKCmludGVyZmFjZSBJRW50aXR5CnsKICAgIHN0cmluZyBOYW1lIHsgZ2V0OyBzZXQ7IH0KfQoKY2xhc3MgRm9vRW50aXR5IDogSUVudGl0eQp7CiAgICBwdWJsaWMgc3RyaW5nIE5hbWUgeyBnZXQ7IHNldDsgfQoKICAgIHB1YmxpYyBGb29FbnRpdHkoKQogICAgewogICAgICAgIE5hbWUgPSAiZm9vIjsKICAgIH0KfQoKaW50ZXJmYWNlIElMZXR0ZXI8VD4gd2hlcmUgVDpJRW50aXR5CnsKICAgIHN0cmluZyBFbnRpdHlNZXRhZGF0YSB7IGdldDsgc2V0OyB9CiAgICBMaXN0PFQ+IEdldFJlY29yZHMoKTsKfQoKCmFic3RyYWN0IGNsYXNzIEFic3RyYWN0TGV0dGVyPFQ+IDogSUxldHRlcjxUPiB3aGVyZSBUOklFbnRpdHkKewogICAgcHVibGljIGFic3RyYWN0IHN0cmluZyBFbnRpdHlNZXRhZGF0YSB7IGdldDsgc2V0OyB9CiAgICBwdWJsaWMgYWJzdHJhY3QgTGlzdDxUPiBHZXRSZWNvcmRzKCk7Cn0KCmNsYXNzIEpvYkxldHRlcjxUPiA6IEFic3RyYWN0TGV0dGVyPFQ+IHdoZXJlIFQgOiBJRW50aXR5LCBuZXcoKQp7CiAgICBwdWJsaWMgb3ZlcnJpZGUgc3RyaW5nIEVudGl0eU1ldGFkYXRhIHsgZ2V0OyBzZXQ7IH0KICAgIHB1YmxpYyBvdmVycmlkZSBMaXN0PFQ+IEdldFJlY29yZHMoKSB7IHJldHVybiBudWxsOyB9CgogICAgcHVibGljIEpvYkxldHRlcigpCiAgICB7CiAgICAgICAgdmFyIGVudGl0eSA9IG5ldyBUKCk7CiAgICAgICAgRW50aXR5TWV0YWRhdGEgPSBlbnRpdHkuTmFtZTsKICAgIH0KfQoKCgpwdWJsaWMgY2xhc3MgVGVzdAp7CglzdGF0aWMgTGlzdDxUPEs+PiBDcmVhdGVMZXR0ZXJMaXN0PFQsIEs+KCkgd2hlcmUgVCA6IEFic3RyYWN0TGV0dGVyPEs+LCBuZXcoKSB3aGVyZSBLIDogSUVudGl0eQoJewoJICAgIHJldHVybiBuZXcgTGlzdDxUPEs+PiB7IG5ldyBUPEs+KCksIH07Cgl9CgkKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKCQl2YXIgam9iTGV0dGVyTGlzdCA9IENyZWF0ZUxldHRlckxpc3Q8Sm9iTGV0dGVyLCBGb29FbnRpdHk+KCk7CgkgICAgZm9yZWFjaCAodmFyIGxldHRlciBpbiBqb2JMZXR0ZXJMaXN0KQoJICAgIHsKCSAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUobGV0dGVyLkVudGl0eU1ldGFkYXRhKTsKCSAgICB9Cgl9Cn0=
compilation info
prog.cs(48,21): error CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 1 error(s), 0 warnings
stdout