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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:42:15+00:00 2026-06-08T08:42:15+00:00

I really don’t understand what is wrong with this code. It is throwing several

  • 0

I really don’t understand what is wrong with this code. It is throwing several errors:

error CS0079: The event core.Events.Event.thisEvent can only appear
on the left hand side of += or -= operator

error CS0070: The event core.Events.Event.thisEvent can only appear
on the left hand side of += or -= when used outside of the type
core.Events.Event

error CS1502: The best overloaded method match for
System.Delegate.Combine(System.Delegate, System.Delegate) has some
invalid arguments

error CS1503: Argument #1 cannot convert object expression to type
System.Delegate

What am I doing wrong and how can I fix this?

using System;
using System.Runtime.CompilerServices;

namespace core.Events
{
    public class Event
    {
        public delegate void EventDelegate (object from,EventArgs args);

        public event Event.EventDelegate thisEvent {
            [MethodImpl(MethodImplOptions.Synchronized)]
            add {
                this.thisEvent += (Event.EventDelegate)Delegate.Combine (this.thisEvent, value);
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            remove {
                this.thisEvent -= (Event.EventDelegate)Delegate.Remove (this.thisEvent, value);
            }
        }

        public void call (object from, EventArgs args)
        {
            this.thisEvent (from, args);
        }
    }
}

Thank you in advance for your help I think I am just super tired and lost in source…

  • 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-08T08:42:16+00:00Added an answer on June 8, 2026 at 8:42 am

    It is a similar kind of mistake as using the name of the property in the getter of the property. Which normally causes SO, this mistake is however caught early. You need to create a private backing field to store the delegate, the compiler no longer auto-generates it for you when you explicitly write the accessors. Thus:

        private EventDelegate eventImpl;
    
        public event Event.EventDelegate thisEvent {
            [MethodImpl(MethodImplOptions.Synchronized)]
            add {
                this.eventImpl += value;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            remove {
                this.eventImpl -= value;
            }
        }
    
        public void call(object from, EventArgs args) {
            var handler = this.eventImpl;
            if (handler != null) handler(from, args);
        }
    

    Note the call() implementation, it avoids a crash if nobody subscribed the event and another crash when threads unsubscribe the event. And I used the short-cut notation to avoid calling Delegate.Combine() explicitly. Beware that this code isn’t actually different from what the compiler auto-generates if you don’t use accessors.

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

Sidebar

Related Questions

I really don't understand what I'm doing wrong, but according to Adobe, this is
I use this code to get Server Date but I really don't understand.CreateDateTime() is
I really don't understand this. I have a simple ASP with 3 div in
There is something that I really don't understand with the HttpListener. The code below
I really don't understand why this function doesn't work: function GetNomRepertoireTemporaire:WideString; var PathLocal :
I really don't understand this. I downloaded the recent version of xCode 3.2.5 and
I really don't understand Javascript. In PHP, I can remove quotes like this: $tags_array
I really don't understand how all this flags working since I do exactly what
I really don't understand the striping behaviour resulting from the following code. I had
I really don't know squat about java memory management, so this is entirely my

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.