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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:43:30+00:00 2026-05-26T22:43:30+00:00

If a class declares a event then event can be fired only from that

  • 0

If a class declares a event then event can be fired only from that class. what is the reason for the restriction of the event invocation?

using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication12
{
    delegate void Function();

    class EventHandling
    {
        public event Function fun;

        public void AddEvents(Function events)
        {
            fun += events;
        }

        public void Notify()
        {
            fun();
        }
    }

    class Program
    {

        static void Main(string[] args)
        {
            EventHandling aEvtHandler = new EventHandling();
            Function aFun = new Function(Display);
            aEvtHandler.AddEvents(aFun);
            aEvtHandler.Notify();
        }

        static void Display()
        {
            Console.WriteLine("in the display");
            Console.Read();
        }
    }
}
  • 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-26T22:43:31+00:00Added an answer on May 26, 2026 at 10:43 pm

    Firing an event only makes sense from the class that defined it.

    If I create a Bike class and that class contains an EngineStarted event, when is that event raised? When something happens that makes the engine start. So, the event being fired means that the instance of the class (a Bike object) reports to the outside world that the engine was started.

    It makes no sense that another object would report to the world that the engine of a particular bike started, without the bike itself having reported that first.

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

Sidebar

Related Questions

In my class I want to declare an event that other classes can subscribe
When name of a field-like event SomeNews is used inside a class that declares
Quote from: http://msdn.microsoft.com/en-us/library/aa645739(VS.71).aspx "Invoking an event can only be done from within the class
Ok, so I have a base class which declares the event StatusTextChanged . My
I want to subscribe and unsubscribe from a ToolStripButton 's Click event using a
I researched the ItemAdd event and created a class module that follows the example.
Using reflection you can get pretty much everything relating to a class. You can
I have a class that offers up a few events. That class is declared
I was trying to figure out what happens when a derived class declares a
I have a MustInherit .NET class which declares a constructor with an integer parameter.

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.