Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:12:44+00:00 2026-05-25T19:12:44+00:00

Hi guys i’m having a problem regarding returning multiple values from a method. I’m

  • 0

Hi guys i’m having a problem regarding returning multiple values from a method. I’m using ‘out’ to return other value from a method, here the snippet:

public DataTable ValidateUser(string username, string password, out int result)
{
    try
    {
        //Calls the Data Layer (Base Class)
        if (objDL != null)
        {
            int intRet = 0;
            sqlDT = objDL.ValidateUser(username, password, out intRet);
        }
    }
    catch (Exception ex)
    {
        ErrorHandler.Handle(ex);
        OnRaiseErrorOccuredEvent(this, new ErrorEventArgs(ex));
    }
    return sqlDT;
}

then when i compile having a error like this:

“The out parameter ‘return’ must be assigned to before control leaves the current method”

Anyone guys can help me solve this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:12:45+00:00Added an answer on May 25, 2026 at 7:12 pm

    That means in all possibilities (inside and outside the if, in the catch), your result variable must be assigned.

    The best approach would be to give it a default value at the start of the function:

    public DataTable ValidateUser(string username, string password, out int result)
    {
        result = 0;
        try
        {
            //Calls the Data Layer (Base Class)
        if (objDL != null)
        {
            int intRet = 0;
            sqlDT = objDL.ValidateUser(username, password, out intRet);
            result = intRet;
        }
    //....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys, I am using dynamic programming approach to solve a problem. Here is a
guys, I have the problem when copying database from local assets folder to /data/data/package_name/databases
Guys, I've came across this problem I can't resolve myselg, I'm pretty sure I
Guys, I am using SQL Server 2000 and executing the sp_columns stored procedure to
guys which text editor is good for Rubyonrails? i m using Windows and i
Guys that is code copied from a book (Programming Windows 5th edition): #include <windows.h>
Guys, I'm trying to finish up my homework but I'm having some problems here
Guys, I know this is going to turn out to be a simple answer,
Guys if the int c=10001; which is a binary value.If i want to process
Guys i have tried to refresh my page with a button.. <input type=reset value=Refresh

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.