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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:19:54+00:00 2026-06-10T13:19:54+00:00

I am trying to pass a member reference to a parameter of another method.

  • 0

I am trying to pass a member reference to a parameter of another method. It’s a lazy loader property that initializes on first reference (see Name property in code example). The goal is to be able to pass the reference of the Name property to the GetName() method without its Get accessor being evaluated as it’s passed through. Instead, I want to reference it deeper in the stack so that its Get accessor is triggered at that point.

I am getting closer to figuring this out after happening up Actions. In my below code, I have the code GetName(Function() (Name)) which passes the property reference to GetName(). Within GetName()‘, I have the line Name.Invoke(). I know this works because the breakpoint I put in the get accessor is not tripped as its passed through the method. It’s only invoked when I call .Invoke(). However, I need to be able to return the value of the Name property as the string it returns rather than just trigger it without returning anything.

Also, while this is in VB, I am also fluent in c#, but I might ask questions about the VB.NET-equivalent syntax.

Class TestClass

    Private _Name As String
    Private ReadOnly Property Name As String
        Get
            If _Name Is Nothing Then _Name = "Bob"
            Return _Name
        End Get
    End Property

    Sub AccessPropertyValue()

        GetName(Function() (Name))

    End Sub

    Sub GetName(Name As Action)

        Name.Invoke()

    End Sub
End Class

Update: Thanks to ChaosPandion, I was able to do this:

Sub AccessPropertyValue()

    Dim s As String = GetName(Function() (Name))

End Sub

Function GetName(Name As Func(Of String)) As String

    Return Name.Invoke()

End Function

I hope this helps others.

  • 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-10T13:19:55+00:00Added an answer on June 10, 2026 at 1:19 pm

    You’ll want to use System.Func(Of String) rather than System.Action which is a Sub.

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

Sidebar

Related Questions

I'm trying to pass a member function pointer as a template parameter. Here is
When trying to pass a CGPoint to a method the point is passed, but
In Javascript I'm trying to pass a class member to a jQuery function, but
I am trying to pass a member function to libevent which should be treated
I'm trying to pass a temporary object to another object constructor for the second
I'm trying to pass a variable by reference to a different class, but I
I am trying to pass a member function to QtConcurrent::run() I have tried to
Hi I am trying to pass a callback which is a member function. I
I'm trying to write a functor that I can pass to std::sort that will
I am trying to pass a selected value from a combo box that is

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.