Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

tommmyyy123

@tommmyyy123
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • event in c#
    T tommmyyy123

    Thanks

    C# csharp help question

  • event in c#
    T tommmyyy123

    And how I test the null handler list in Main : if (evt.SomeEvent == null) Console.WriteLine(“Event refered the null list”);

    C# csharp help question

  • event in c#
    T tommmyyy123

    Hi, I have the code:

    using System;
    // Declare a delegate type for an event.
    delegate void MyEventHandler();
    // Declare a class that contains an event.
    class MyEvent
    {
    public event MyEventHandler SomeEvent;
    // This is called to raise the event.
    public void OnSomeEvent()
    {
    if (SomeEvent != null)
    SomeEvent();
    }
    }
    class EventDemo
    {
    // An event handler.
    static void Handler()
    {
    Console.WriteLine(“Event occurred”);
    }
    static void Main()
    {
    MyEvent evt = new MyEvent();
    // Add Handler() to the event list.
    evt.SomeEvent += Handler;
    if (evt.SomeEvent == null) Console.WriteLine(“Ev. nu are nici o metoda in lista”);
    // Raise the event.
    evt.OnSomeEvent();
    }
    }

    Why in the case of the second if (from Main) I have compiler error: error CS0070: The event ‘ConsoleApplication2.MyEvent.SomeEvent’ can only appear on the left hand side of += or -= (except when used from within the type ‘ConsoleApplication2.MyEvent’)

    And in the case of te first if it is OK ?

    tom

    C# csharp help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups