Suraj Kaushik's Blog

2 share my mistakes and lessons

Compiler Error Message: CS0161: ‘users.login(string, string)’: not all code paths return a value

Not All code paths retun a value. comes when we set any function to return any kind of datatype value other than void as

Line 25:     public string login(string userid, string pwd)

above funciton must return string value in every case, no matter if it returns a blank string. Hence, if you din’t check every condition with if and else statement or any excepetions is raised at any point, this kind of error may come in existence. Thus be sure, that your every if block has supportive else block or you are using exception catch code otherwise. And your each block is  returns the value with required datatype.

Server Error in ‘/dcorp’ Application.


Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0161: ‘users.login(string, string)’: not all code paths return a value

Source Error:

Line 23:       }

Line 24:

Line 25:     public string login(string userid, string pwd)

Line 26:     {

Line 27:         db db = new db(); // database class instance;

Source File: d:\developers\Suraj\projects\dunecorporation\App_Code\users.cs    Line: 25

, , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>