Skip to content

Instantly share code, notes, and snippets.

@lauromoura
Created August 29, 2019 14:19
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 lauromoura/3dff20b89a6610ed3a4a83d7156dd8b0 to your computer and use it in GitHub Desktop.
Save lauromoura/3dff20b89a6610ed3a4a83d7156dd8b0 to your computer and use it in GitHub Desktop.
C#: Using value types as event arguments
using System;
namespace NewArgs
{
public class EventPlayground
{
public event EventHandler<int> OnSelectedIndex;
public void Select(int x) {
OnSelectedIndex?.Invoke(this, x);
}
static void Main()
{
var emitter = new EventPlayground();
emitter.OnSelectedIndex += (object sender, int e) =>
{
Console.WriteLine($"Selected Index {e}");
};
emitter.Select(42);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment