c# - Not all code paths return a value when using Task.ContinueWith -
so have function have return in if-else
still getting compilation error:
not code paths return value
public async task<bool> deletepost(string update_id, string authid) { if (utility.networkstatus.hasinternetaccess) { await apis.deletepost.deletepostapi(update_id, authid).continuewith((t) => { if (t.status == taskstatus.rantocompletion) { if (t.result != null) { return t.result.status == 200; } else { return false; //empty result, api failed //not implemented } } else { return false; //task failed //not implemented } }); } else { return false; //no network //not implemented } }
can tell me doing wrong?
yes. don't return result of continuation of deletepostapi
:
public async task<bool> deletepost(string update_id, string authid) { if (utility.networkstatus.hasinternetaccess) { return await apis.deletepost.deletepostapi(update_id, authid).continuewith((t) => { if (t.status == taskstatus.rantocompletion) { if (t.result != null) { return t.result.status == 200; } else { return false; //empty result, api failed //not implemented } } else { return false; //task failed //not implemented } }); } else { return false; //no network //not implemented } }
Comments
Post a Comment