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

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -