Extension Methods not Recognized

前端 未结 12 1045
抹茶落季
抹茶落季 2020-12-10 00:09

What is necessary to have an extension method honored when it exists in an imported assembly? I built one in a class library project but it is not recognized in my web proj

12条回答
  •  孤城傲影
    2020-12-10 01:07

    Make sure if using templates, your template declaration matches what is declared in the method signature with, "this"..

    So,

    SomeClass test = new SomeClass();
    
    extensionMethod(this SomeClass>, string val)
    {
    }
    

    the extension method will not show up because of the lazy wrapper.

提交回复
热议问题