c# - Invalid expression term error in the code -


  • error 1 best overloaded method match 'int.tryparse(string, out int)' has invalid arguments
  • error 2 argument 1: cannot convert 'int' 'string'

    it gives me error in "int.tryparse(surveys.first(), out id);"

       l       var surveys = (from su in dbcontext.surveys                                su.username == su.username                                 select su.id); if(surveys.count() > 0)             {              int id = 0;              int.tryparse(surveys.first(), out id);                return id;              }              return 0; 

remove int tryparse();

int.tryparse(surveys.first(), out int id); 

should be

int.tryparse(surveys.first(), out id); 

change :-

list<surveycontext> surveys = (from su in dbcontext.surveys                                           su.username == su.username                                            select su.id).tolist(); 

to

list<string> surveys = (from su in dbcontext.surveys                                           su.username == su.username                                            select su.id); 

you trying select string type in linq , putting in list<sometype> should list<int>.

  var surveys = (from su in dbcontext.surveys                                               su.username == su.username                                                select su.id);    //code follows   int.tryparse(surveys.first(), out id); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -