Skip to content

Instantly share code, notes, and snippets.

@jasondown

jasondown/Car.cs Secret

Created August 3, 2021 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasondown/e08a54302ef92ebf05c138f421521d74 to your computer and use it in GitHub Desktop.
Save jasondown/e08a54302ef92ebf05c138f421521d74 to your computer and use it in GitHub Desktop.
public class Car
{
private readonly Radio _radio;
public event EventHandler<RadioEventArgs> RadioTogglePower;
public Car(Radio radio)
{
// omitting guard clause
_radio = radio;
_radio.TogglePower += OnRadioTogglePower;
}
private void OnRadioTogglePower(object sender, RadioEventArgs e)
{
if (RadioTogglePower != null) RadioTogglePower(sender, e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment