Skip to content

Commit 95afc8f

Browse files
author
Ron Petrusha
authored
Merge pull request #5913 from dotnet/master
Update live with current master
2 parents 6c48077 + 4b36aba commit 95afc8f

17 files changed

+311
-296
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Thank you for your interest in contributing to the .NET documentation!
44

5+
> We're in the process of moving our guidelines into a site-wide contribution guide.
6+
> To see the new guidance, visit [Microsoft Docs contributor guide overview](https://docs.microsoft.com/contribute/).
7+
58
The document covers the process for contributing to the articles and code samples that are hosted on the [.NET documentation site](https://docs.microsoft.com/dotnet). Contributions may be as simple as typo corrections or as complex as new articles.
69

710
* [Process for contributing](#process-for-contributing)

docs/csharp/programming-guide/events/codesnippet/CSharp/how-to-implement-interface-events_1.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,12 @@ event EventHandler IShape.OnDraw
7474
public void Draw()
7575
{
7676
// Raise IDrawingObject's event before the object is drawn.
77-
EventHandler handler = PreDrawEvent;
78-
if (handler != null)
79-
{
80-
handler(this, new EventArgs());
81-
}
77+
PreDrawEvent?.Invoke(this, EventArgs.Empty);
78+
8279
Console.WriteLine("Drawing a shape.");
8380

84-
// RaiseIShape's event after the object is drawn.
85-
handler = PostDrawEvent;
86-
if (handler != null)
87-
{
88-
handler(this, new EventArgs());
89-
}
81+
// Raise IShape's event after the object is drawn.
82+
PostDrawEvent?.Invoke(this, EventArgs.Empty);
9083
}
9184
}
9285
public class Subscriber1
@@ -95,7 +88,7 @@ public class Subscriber1
9588
public Subscriber1(Shape shape)
9689
{
9790
IDrawingObject d = (IDrawingObject)shape;
98-
d.OnDraw += new EventHandler(d_OnDraw);
91+
d.OnDraw += d_OnDraw;
9992
}
10093

10194
void d_OnDraw(object sender, EventArgs e)
@@ -109,7 +102,7 @@ public class Subscriber2
109102
public Subscriber2(Shape shape)
110103
{
111104
IShape d = (IShape)shape;
112-
d.OnDraw += new EventHandler(d_OnDraw);
105+
d.OnDraw += d_OnDraw;
113106
}
114107

115108
void d_OnDraw(object sender, EventArgs e)
@@ -139,4 +132,4 @@ static void Main(string[] args)
139132
Sub1 receives the IDrawingObject event.
140133
Drawing a shape.
141134
Sub2 receives the IShape event.
142-
*/
135+
*/

docs/csharp/programming-guide/events/how-to-implement-interface-events.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,17 @@ An [interface](../../../csharp/language-reference/keywords/interface.md) can dec
3737
}
3838
protected virtual void OnShapeChanged(MyEventArgs e)
3939
{
40-
if(ShapeChanged != null)
41-
{
42-
ShapeChanged(this, e);
43-
}
40+
ShapeChanged?.Invoke(this, e);
4441
}
4542
}
4643

4744
}
4845
```
4946

5047
## Example
51-
The following example shows how to handle the less-common situation in which your class inherits from two or more interfaces and each interface has an event with the same name. In this situation, you must provide an explicit interface implementation for at least one of the events. When you write an explicit interface implementation for an event, you must also write the `add` and `remove` event accessors. Normally these are provided by the compiler, but in this case the compiler cannot provide them.
48+
The following example shows how to handle the less-common situation in which your class inherits from two or more interfaces and each interface has an event with the same name. In this situation, you must provide an explicit interface implementation for at least one of the events. When you write an explicit interface implementation for an event, you must also write the `add` and `remove` event accessors. Normally these are provided by the compiler, but in this case the compiler cannot provide them.
5249

53-
By providing your own accessors, you can specify whether the two events are represented by the same event in your class, or by different events. For example, if the events should be raised at different times according to the interface specifications, you can associate each event with a separate implementation in your class. In the following example, subscribers determine which `OnDraw` event they will receive by casting the shape reference to either an `IShape` or an `IDrawingObject`.
50+
By providing your own accessors, you can specify whether the two events are represented by the same event in your class, or by different events. For example, if the events should be raised at different times according to the interface specifications, you can associate each event with a separate implementation in your class. In the following example, subscribers determine which `OnDraw` event they will receive by casting the shape reference to either an `IShape` or an `IDrawingObject`.
5451

5552
[!code-csharp[csProgGuideEvents#10](../../../csharp/programming-guide/events/codesnippet/CSharp/how-to-implement-interface-events_1.cs)]
5653

docs/csharp/tuples.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ Beginning with C# 7.3, tuple types support the `==` and `!=` operators. These op
153153

154154
[!code-csharp[TupleEquality](../../samples/snippets/csharp/tuples/tuples/program.cs#Equality "Testing tuples for equality")]
155155

156-
There are several rules that make tuple equality tests more convenient. Tuple equality performs [lifted conversions](/dotnet/csharp/language-reference/language-specification/conversions.md#lifted-conversion-operators) if one of the tuples is a nullable tuple, as shown in the following code:
156+
There are several rules that make tuple equality tests more convenient. Tuple equality performs [lifted conversions](/dotnet/csharp/language-reference/language-specification/conversions#lifted-conversion-operators) if one of the tuples is a nullable tuple, as shown in the following code:
157+
157158

158159
[!code-csharp[NullableTupleEquality](../../samples/snippets/csharp/tuples/tuples/program.cs#NullableEquality "Comparing Tuples and nullable tuples")]
159160

0 commit comments

Comments
 (0)