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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:29:50+00:00 2026-06-15T05:29:50+00:00

I am working on lazy object composer class Bitset { private List<bool> _data; public

  • 0

I am working on lazy object composer

class Bitset
{ 
   private   List<bool> _data;   
   public Bitset(List<bool> vector)
   {
      _data = vector;
   }
   public virtual bool  GetElement (int i)
   {
      return _data[i];
   }


   public Bitset(){}

}
class BitsetComposer:Bitset
{        
   readonly private Bitset _a,_b;
   private Func<bool,bool,bool> _composer;
   public BitsetComposer(Bitset a,Bitset b, Func<bool,bool,bool> composer)
   {
      this._a=a;
      this._b=b;
      this._composer=composer;
   }

   public override bool GetElement (int i)
   {
      return _composer(_a.GetElement(i),_b.GetElement(i));
   }

   public static BitsetComposer operator & (BitsetComposer a, BitsetComposer b)
   {
      return new BitsetComposer(a,b,BitsetComposer.And);
   }

   public static bool And(bool a,bool b){return a&b;}

}

This is not fine, because, it would be desired that & can also take base class

//replaced with
//public static BitsetComposer operator & (BitsetComposer a, BitsetComposer b)
public static BitsetComposer operator & (Bitset a, Bitset b)
{
   return new BitsetComposer(a,b,BitsetComposer.And);
}

But I got error:

Error CS0563: One of the parameters of a binary operator must be the containing type

  • 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-15T05:29:51+00:00Added an answer on June 15, 2026 at 5:29 am

    If both operands are expected to be of base class type, you only need to move the operator code to the base class.

    From 7.2.2 Operator overloading:

    User-defined operator declarations always require at least one of the
    parameters to be of the class or struct type that contains the
    operator declaration. Thus, it is not possible for a user-defined operator to have the
    same signature as a predefined operator.

    class Bitset
    { 
       private   List<bool> _data;   
       public Bitset(List<bool> vector)
       {
          _data = vector;
       }
       public virtual bool  GetElement (int i)
       {
          return _data[i];
       }
    
       public Bitset(){}
    
    
       public static BitsetComposer operator &(Bitset a, Bitset b)
       {
           return new BitsetComposer(a, b, BitsetComposer.And);
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on an object class for my iPhone app that lazy
I have an Entity like this: public class Configuration { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name
I'm working with lazy loading a Gallery of images (one class for the Gallery
I'm working with backbone and lazy-loading both templates and data for one of my
I'm working on a project that has a rich object model with various sets
I'd like to use .NET 's Lazy<T> class to implement thread safe caching. Suppose
Hi Stackoverflow people, I am working with class based views and for a test
I have a Comment class with, among others, an Author property: public class Comment
Trying to use asynctask for lazy loading. Its 75% working fine; able to run
I just configured @PersistenceContext(type=PersistenceContextType.EXTENDED) on my DAO classes to get lazy loading working on

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.