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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:23:19+00:00 2026-05-24T14:23:19+00:00

These is my code: public static Symbol operator + (Symbol op1, Symbol op2) {

  • 0

These is my code:

    public static Symbol operator + (Symbol op1, Symbol op2)
    {
        Symbol op3 = new Symbol() { op3.type = Type.Value };

        object o1 = null;
        object o2 = null;

        object replacement;
        try
        {
            o1 = op1.value.Value;
            o2 = op2.value.Value;

            if (o1 is string || o2 is string)
                replacement = o1.ToString() + o2.ToString();
            else if (o1 is double && o2 is double)
                replacement = (double)o1 + (double)o2;
            else
                throw new Exception("only to be caught");
        }
        catch
        {
            op3.type = Type.Invalid;
            op3.value = null;
            replacement = op3;
        }
        Debug.WriteLine(String.Format("ExpressionEvaluator {0} + {1} = {2}", o1, o2, replacement));

        op3.value = new Naked(replacement, typeof(bool));
        return op3;
    }

I gate the following error:
One of the parameters of a binary operator must be the containing type

Any idea what is wrong?

  • 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-24T14:23:20+00:00Added an answer on May 24, 2026 at 2:23 pm

    Based on the error it sounds like you declared your operator+ inside a type other than Symbol. C# requires that at least one of the types listed in the binary operator be the type in which the binary operator is defined

    Update

    As Eric pointed out, when the declaring type is a struct (named say S) then one of the operands must be S or S?

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

Sidebar

Related Questions

Here's the relevant code: public static String[] runTeams (String CPUcolor) { boolean z =
Consider the following code public static void method(String[] srgs){ try{ }catch(){ System.out.println(Hello World +
When I try this code public static void Main() { Console.WriteLine(Total bytes : +
I have this code: public static final <TypeVO extends BaseVo> List<SelectItem> populateSelectBoxForType( final Class<TypeVO>
Given the following code public static Bitmap PrintWindow(IntPtr hWnd) { int width = GetWindowInfo(hWnd).rcWindow.Width;
See the code snippets below: Code 1 public class A { static int add(int
I am just starting with this, and with this code: public static void main(String[]
Is there a way to make this code work? LogonControl.java @Audit(AuditType.LOGON) public void login(String
I normally in my projects use such these code: If user.IsInRole(Admin) Then deleteButton.Visible =
I am trying to test some of these code here http://ha.ckers.org/xss.html on my code.

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.