Skip to content

Fix nullable event warning in interface events documentation #47684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace ImplementInterfaceEvents
}
public class Shape : IDrawingObject
{
public event EventHandler ShapeChanged;
public event EventHandler? ShapeChanged;
void ChangeShape()
{
// Do something here before the event…
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,21 +686,18 @@ public class MyEventArgs : EventArgs
}
public class Shape : IDrawingObject
{
public event EventHandler ShapeChanged;
public event EventHandler? ShapeChanged;
void ChangeShape()
{
// Do something here before the event
// Do something here before the event

OnShapeChanged(new MyEventArgs(/*arguments*/));

// or do something here after the event.
}
protected virtual void OnShapeChanged(MyEventArgs e)
{
if (ShapeChanged != null)
{
ShapeChanged(this, e);
}
ShapeChanged?.Invoke(this, e);
}
}
}
Expand Down
Loading