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 6532015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:56:53+00:00 2026-05-25T09:56:53+00:00

I use asp.net 4 and c#. I would like to know if could be

  • 0

I use asp.net 4 and c#.

I would like to know if could be possible return more than one return type in a Method.

As example in this method I return only a single bool type.

   protected bool IsFilePresent()
    {
            return File.Exists(Server.MapPath("/myFile.txt"));
    }

But lets imagine I would like return also a string type using in the same method like:

string lineBase = File.ReadAllText(Server.MapPath("/myFile.txt"));

Is possible to do it?

I would appreciate some code example. Many Thanks.

  • 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-25T09:56:54+00:00Added an answer on May 25, 2026 at 9:56 am

    No, it’s not possible to return multiple, different values. You have a few alternatives:

    1. One is to make a class or struct that has each of the things you want to return as properties or fields.

    2. Another is to use out parameters, where you pass in a variable to a method, which the method then assigns a value to.

    3. You could also use ref parameters (pass by reference), which is similar to out, but the variable you pass in needs to have been assigned before you call the method (i.e. the method changes the value).

    In your case, as cjk points out, you could just have the method return a string with the file contents, or null to indicate that the file didn’t exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use standard ASP.NET file download response, like in other Stack
I would like to use RestSharp to connect to my ASP.NET WebApi services. The
how would you use JQuery with asp.net Code-Behind what i mean by that: i
What would be the best Calendar plugin I may use in a asp.net application
I would like to know if the following is possible: As part of the
i run a social networking site written in asp.net and would like to open
I would like to use HTML input file type in my aspx page to
If you were starting a new web development project would you use ASP.Net MVC
Currently I am working on an ASP.net webforms project where I would like to
I would like to know if there is a way to integrate YAF.NET to

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.