File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed
docs/csharp/programming-guide/events
samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideEvents/CS Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ namespace ImplementInterfaceEvents
29
29
}
30
30
public class Shape : IDrawingObject
31
31
{
32
- public event EventHandler ShapeChanged ;
32
+ public event EventHandler ? ShapeChanged ;
33
33
void ChangeShape ()
34
34
{
35
35
// Do something here before the event…
Original file line number Diff line number Diff line change @@ -686,21 +686,18 @@ public class MyEventArgs : EventArgs
686
686
}
687
687
public class Shape : IDrawingObject
688
688
{
689
- public event EventHandler ShapeChanged ;
689
+ public event EventHandler ? ShapeChanged ;
690
690
void ChangeShape ( )
691
691
{
692
- // Do something here before the event�
692
+ // Do something here before the event…
693
693
694
694
OnShapeChanged ( new MyEventArgs ( /*arguments*/ ) ) ;
695
695
696
696
// or do something here after the event.
697
697
}
698
698
protected virtual void OnShapeChanged ( MyEventArgs e )
699
699
{
700
- if ( ShapeChanged != null )
701
- {
702
- ShapeChanged ( this , e ) ;
703
- }
700
+ ShapeChanged ? . Invoke ( this , e ) ;
704
701
}
705
702
}
706
703
}
You can’t perform that action at this time.
0 commit comments