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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:28:46+00:00 2026-05-15T10:28:46+00:00

(Not really sure if I phrased the question correctly…) I want to create a

  • 0

(Not really sure if I phrased the question correctly…)

I want to create a lambda expression that would take an Object, attempt to convert it to a passed-in Type, and print to the console whether it was successful or not.

At a glance, the lambda expression may seem a pretty silly way to accomplish this task, but I’d really like to know what I’m doing wrong, so I can better grow my skill set.

VS gives me a designer error about the second “T” in the expression below, telling me it isn’t defined)

This is where I left off:

Sub MyMethod(ByVal param as Object)
    Dim quickMethod = Sub (Of T)(o as Object) 
                          Console.WriteLine(TryCast(o, T) IsNot Nothing)                                
                      End Sub

    quickMethod(Of myClass1)(param)
    quickMethod(Of myClass2)(param)
    quickMethod(Of myClass3)(param) 
    quickMethod(Of myClass4)(param)

    'further logic below... ;)    
End Sub
  • 1 1 Answer
  • 1 View
  • 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-15T10:28:46+00:00Added an answer on May 15, 2026 at 10:28 am

    I can’t speak for VB specifically, but I’m not aware of any such concept in .NET delegates in general. While a delegate type can be generic, I don’t believe you can leave a particular delegate instance “open” in a type parameter, to be provided by the caller. It’s an interesting idea though.

    Of course, you could easily write a generic method to do this, and that’s probably the right way to go. It’s an interesting situation where you could have a single-method interface expressing the desired functionality, but you can’t express that as a delegate type. Hmm. Just for the sake of discussion, the interface could be something like this:

    interface IConverter
    {
        bool IsConvertible<T>(object input);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not really sure exactly how the question should be phrased, so please be
I'm not sure if I phrased that correctly but here's my dilemma. I inherited
I am not really sure how to word the question, but I basically have
Not really sure how to phrase this question so it's generic enough. (and will
I'm not really sure how to ask this question. Suppose I have a class
I'm really not sure how to even phrase the question. So I'll go by
Not really sure how to ask this question because I really don't know what
I am not really sure how to get data out of this nested object
Sorry, I'm not sure how to phrase that and I'm really not very good
Not really sure what's causing this, all I've found on google is that forgetting

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.