Could someone please help me to understand how to get all parameters passed to delegate inside delegate itself?
I have class :
public class ShopManager : ShopEntities
{
public ShopManager getWhere(Func<Object, Object> dataList)
{
var x = dataList.???; // how to get arguments?
return this;
}
public Object getLike(Object dataValue)
{
return dataValue;
}
}
Then i call it as :
ShopManager shopManager = new ShopManager()
var demo = shopManager.getWhere(xxx => shopManager.getLike("DATA"));
The question is : how to get passed parameters “xxx” and “DATA” inside method getWhere()?
Thanks in advance.
You can’t because it’s the other way around. You can’t get the arguments because the delegate does not hold them; the
getWheremethod will need to pass a value for thexxxparameter when invoking the delegate. The anonymous method that the delegate refers to will then receive this value as thexxxparameter, and in turn pass the string"DATA"as argument for thedataValueparameter when callinggetLike. The argument values as such are not part of the delegate’s state.If you want to get information about the parameters as such (not their values), you can do that: