Skip to content

MouseEventArgs and KeyEventArgs are not base types of EventArgs #14062

Closed

Description

@keni1

This page says: "This example demonstrates how delegates can be used with methods that have parameters of a type that are base types of the delegate signature parameter type"

But neither MouseEventArgs or KeyEventArgs are base types of EventArgs, but the opposite is true.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Activity

  1. svick commented on Aug 28, 2019

    @svick
    Member

    I think the page is correct: in the example, the method in question is:

    private void MultiHandler(object sender, System.EventArgs e)  

    And the delegate signatures are:

    public delegate void KeyEventHandler(object sender, KeyEventArgs e);
    public delegate void MouseEventHandler(object sender, MouseEventArgs e);

    So it's saying that EventArgs is the base type of KeyEventArgs and MouseEventArgs, which is correct.

    Maybe the use of plural and singular is confusing? The text talks about "methods" and "delegate signature", but the example has a single method and multiple delegate signatures.

  2. self-assigned this
    on Aug 28, 2019
  3. added this to the August 2019 milestone on Aug 28, 2019
  4. rpetrusha commented on Aug 28, 2019

    @rpetrusha
    Contributor

    Thanks for submitting your feedback, @keni1. As @svick points out, the documentation is correct. But as he also points out, this page is confusing, and the contravariance example requires very careful reading (and re-reading) before it becomes clear. I've opened #14072 to attempt to add clarity to the description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions