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

  • Home
  • SEARCH
  • 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 9138365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:14:49+00:00 2026-06-17T09:14:49+00:00

Is it possible to pass in an object reference to a method signature for

  • 0

Is it possible to pass in an object reference to a method signature for classes that share the same base class? i.e., simplified:

public class ClassA : System.Web.UI.Control 
public class ClassB : System.Web.UI.Control

In Page:

private void SetCurrentView(ref Control ctrl)
{
  ctrl.Visible = true;
}

protected void Page_Load(object sender, System.EventArgs e)
{
  aClass = new ClassA();
  bClass = new ClassB();
  SetCurrentView(ref aClass);
  SetCurrentView(ref bClass);
}

Obviously, as is, this does not work, and casting it in the method call would not be an assignable reference. Thoughts?

  • 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-17T09:14:49+00:00Added an answer on June 17, 2026 at 9:14 am

    No, but you do not need ref here anyway.

    To set the visibility, the following does exactly what you need:

    private void SetCurrentView(Control ctrl)
    {
      ctrl.Visible = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to instantiate an object and pass a reference to that new
Is that possible to make a UIToolbarButton pass an object to its target by
Possible Duplicate: Is Java pass-by-reference? I found an unusual Java method today: private void
Possible Duplicate: Is Java “pass-by-reference”? I want to know how to pass an object
It is possible to pass uninitialized object to a parent class like in the
Possible Duplicate: How to pass object from one activity to another in Android I
Is it possible to pass a delegate to a WCF remote object from the
Possible Duplicate: pass by reference not working I was going through some of the
Is it possible to pass a request from java servlet and read that request
Is it possible to pass TargetActivity.class to another activity and do something like: //

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.