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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:54:07+00:00 2026-05-12T14:54:07+00:00

I am writing an application which checks for conditions (ie if a bool is

  • 0

I am writing an application which checks for conditions (ie if a bool is true or false) but it can take any object as a parameter to the func, which derives from HtmlControl.

My func looks like this:

Func<HtmlControl, bool> func

HtmlControl is a base class for all controls in an API, which I use (ArtOfTest WebAII).

I have a class with the following structure:

static class StartTest<T> where T : HtmlControl, new
{

 public static Manager Check (string Url, Func<T, bool> Condition) {}

 public static int Condition(Manager m, string element, Func<T, bool> func, T t) {}
 }

I am using the new constraint because in a collection, there is an error that the type cannot be abstract so when I specify the new constraint, that can only be the concrete, instantiated types.

I want to write something like this:

Method1("Next parameter is a parameter to the func. If I don't write the cast, the   compiler will think its the abstract HtmlControl class, right?", (HtmlImage) img => img.Alt.Length == 0);

However, this errors.

(The stuff in speech marks is part of this question).

When I write the func for a method taking a func as a parameter, how can I pass in a derived type of an abstract class?

The logic is called/consumed from a Windows page codebehind. I make that page generic like so:

  public partial class Window1<T> : Window where T : HtmlControl, new()

But I get an error saying InitializeComponent does not exist in the current context.

  • 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-12T14:54:07+00:00Added an answer on May 12, 2026 at 2:54 pm

    (HtmlImage) img => img.Alt.Length == 0

    You’re trying to cast the whole lambda expression to HtmlImage… If you want to specify the type of the lambda expression parameter, do it like this :

    (HtmlImage img) => img.Alt.Length == 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an application which checks if the method is sythentic or bridge.
I'm wondering about writing an application in Java which can synchronize files across my
Basically, I'm writing a Java Command-line application which accept parameter from user by readLine.
I'm writing a C application which creates a Windows service. I'd like to check
I'm writing an application which is quite graphically heavy and therefore I'm trying to
I am writing an application which is going to allows users to change the
I'm writing an application which plays multiple sounds concurrently, each sound needs to be
I am writing an application which has an authenticity mechanism, using HMAC-sha1, plus a
I am writing an application which produces invoices. I was wondering it there was
I'm writing an application which reads and displays images as ImageIcons (within a JLabel),

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.