I am java developer new to C# concepts. I am trying to call class function from anonymous inner function (in java terms don't know what it is called in C#).
public void test ()
{
this.apiManager.send (RequestMethod.GET, "/admin", "", callback1);
}
ApiCallback callback = new ApiCallback () {
onSuccess = (string response, long responseCode) => {
Debug.Log (response);
Debug.Log (responseCode + "");
test();
},
onError = (string exception) => {
Debug.Log (exception);
}
};
So on doing this I am getting following error
A field initializer cannot reference the nonstatic field, method, or property "test()"
Here is the implementation of ApiCallback
public class ApiCallback
{
public delegate void SuccessCreater (string response, long responseCode);
public delegate void ErrorCreater (string error);
public SuccessCreater onSuccess { get; set; }
public ErrorCreater onError { get; set; }
}