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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:20:53+00:00 2026-06-08T18:20:53+00:00

I have a little simple method where I would like to pass in a

  • 0

I have a little simple method where I would like to pass in a label.

Now by my reading, anything based off the object class should automatically pass by reference, so this was my first try at my method:

        public static void ValiateStepAsInt(String Step, int? Value, Label Error)
        {
            if (Value == null && Step != "")
            {
                Error.Text = "Error!!!";
                return;
            }
            Error.Text = "";
        }

I didn’t get any compilor errors, but whenever i called this, it would set the Error.text, but once it got out of the method, that value would disappear (so not really pass by reference).

So next I added the “ref” option to the Label Error; hoping this might fix the issue, but still the same thing, the method sets it, but once its done, ths value disappears.

What I am missing when trying to pass a label by reference?

  • 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-06-08T18:20:54+00:00Added an answer on June 8, 2026 at 6:20 pm

    You’re resetting the Text property to an empty string just below your conditional statement. Maybe you want to wrap Error.Text = ""; into an else.

    If that’s not it, then perhaps you’re setting the value somewhere else as well and thus overwrite the change in the method you’ve shown us here.

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

Sidebar

Related Questions

I have a simple little code fragment that is frustrating me: HashSet<long> groupUIDs =
This is a very simple question yet I have little knowledge in Linux and
I have a little problem with a simple vbScript. The script has to run
I am writing a simple little DSL for specifying constraints on messages, and Have
A little stuck here. I have a simple question I guess. Given the following
I have very little experience designing databases, and now I want to create a
I have here a long method that takes a little while to execute. I
I would like to build my own custom DI framework based on Java annotations
I am looking for some sort of method to have a user based system
I've started working on a little ruby project that will have sample implementations of

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.