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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:10:33+00:00 2026-05-26T17:10:33+00:00

I have a class, and I declare it like this: public class WhereOrCondition<T> :

  • 0

I have a class, and I declare it like this:

public class WhereOrCondition<T> : WhereCondition<T>

The generic type T is the same for both classes. I am not sure how to declare my classes correctly so that the Generic type used for WhereOrCondition is also used in WhereCondition.

Declaring my class in this way gives me the following error:

Error 1 The type 'T' cannot be used as type parameter 'T' in the generic type or method 'BrainStorm.WhereCondition<T>'. There is no boxing conversion or type parameter conversion from 'T' to 'BrainStorm.DatabaseObject'.

Any ideas on how I can declare my class correctly?

EDIT

The WhereCondition class is declared like so:

public class WhereCondition<T> : IEnumerable<KeyValuePair<string, object>> where T : DatabaseObject 
  • 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-26T17:10:33+00:00Added an answer on May 26, 2026 at 5:10 pm

    You need to put the same where condition on WhereOrCondition<T> so it looks like

    public class WhereOrCondition<T> : WhereCondition<T> where T: DatabaseObject
    

    The rule is a where clause on a sub class must be the same or more restrictive than a where clause on a base class.

    What this says is WhereOrCondition<T> has WhereCondition<T> for a sub class and T must be a DatabaseObject (or a subclass).

    Your code in the comment public class WhereAndCondition<T> where T: WhereCondition<T> is something completly different. That says that T must be a WhereCondition<T> which cannot be true.

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

Sidebar

Related Questions

I have two classes declared like this: class Object1 { protected ulong guid; protected
I have a class like this: class Inner; class Cont { public: Cont(); virtual
I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult
Imagine we have a class like this: class Testee { public: void Func() private:
I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
I want to declare a variable like this in C# public anyType variable; and
I've implemented a class that looks like this interface: [ImmutableObject(true)] public interface ICustomEvent {
I have a class declared like this : namespace nsp1 { class A {
I have an interface defining a method like this : public List<IA> myMethod(); with
I have defined an assembly level attribute class FooAttribute like this: namespace Bar {

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.