c# - Cannot implicitly convert type 'bool' to 'system.threading.tasks.task bool' -
i have error: "cannot implicitly convert type 'bool' 'system.threading.tasks.task bool'" in service implementation code. correct code please.
public task<bool> login(string usn, string pwd)     {         dataclasses1datacontext auth = new dataclasses1datacontext();         var message = p in auth.users                       p.usrname == usn && p.usrpass == pwd                       select p;         if (message.count() > 0)         {             return true;         }         else         {             return false;         }     } 
you need specific whether want operation happen asynchronously or not.
as example async operation :
public async task<bool> login(string usn, string pwd) {     dataclasses1datacontext auth = new dataclasses1datacontext();     var message = await (from p in auth.users                   p.usrname == usn && p.usrpass == pwd                   select p);     if (message.count() > 0)     {         return true;     }     else     {         return false;     } } if don't need async operation, try this:
public bool login(string usn, string pwd) {     dataclasses1datacontext auth = new dataclasses1datacontext();     var message = p in auth.users                   p.usrname == usn && p.usrpass == pwd                   select p;     if (message.count() > 0)     {         return true;     }     else     {         return false;     } } note: async , await compatible .net 4.5 , c# 5.0 , more
Comments
Post a Comment