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; } 

  1. 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; } 
  2. even if mark generic, type t not have text property until t specified more precisely class or interface having text property:

    public list<t> cuttext<t>(list<t> list) t : textbox 

    or

    public list<t> cuttext<t>(list<t> list) t : ianyinterfacehavingtextproperty 

Comments

Popular posts from this blog

javascript - How do you prevent nested queries/catches in sequelize? -

java - Could not retrieve pre-bound Hibernate session - Could not obtain transaction-synchronized Session for current thread -

ruby on rails - ActiveRecord order not working -