c# - VS does not allow me to invoke my extension method -
for reason, vs allows me use long writing of extension method invocation. compiler rejects shorter form:
public static class operationextender {
public static void mymethod(operation ope, int value) { ... }
}
i can invoke way:
operationextender.mymethod(anoperation, 0);
but if type:
anoperation.operationextender(0);
vs generates usual comilation error:
'operationextender.mymethod(operation, int)' not contain definition 'mymethod' , no extension method 'mymethod' accepting first argument of type 'operation' found (are missing using directive or assembly reference?)
if first writing accepted, suppose cannot usung/ns/assembly issue....
because it's not extension method. forgot this
keyword on first parameter (the type being "extended"):
public static void mymethod(this operation ope, int value) { //... }
Comments
Post a Comment