Pass Interface to a generic attribute of a class in C#? -


when this:

public class ball {     iteste<iitem> teste{ get; set; } } 

i got error:

'iitem' must non-abstract type public parameterless constructor in order use parameter 't' in generic type or method

iteste:

public interface iteste<t>          t : iitem, iequatable<t>, new() {     //iteste code } 

iitem:

public interface iitem : iequatable<iitem> {     //iitem code } 

it seems simple question, not find answer. appreciated.

remove new() constraints iteste

iteste:

public interface iteste<t>where t : iitem, iequatable<t> {     //iteste code } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -