Generic function return List C# -
i new in c# , reading generics functions. can*t understand wrong? have, example, function:
public list<t> cuttext (list<t> list) { foreach (var in list) { a.text = "yes"; } return list; }
your function not generic. invalid non-compilable function returns list of unknown type t. either function or class should have
<t>
in declaration in order make generic.for example, this:
public list<t> cuttext<t>(list<t> list) { foreach (var in list) { a.text = "yes"; } return list; }
even if mark generic, type t not have
text
property untilt
specified more precisely class or interface havingtext
property:public list<t> cuttext<t>(list<t> list) t : textbox
or
public list<t> cuttext<t>(list<t> list) t : ianyinterfacehavingtextproperty
Comments
Post a Comment