Skip to content
Merged
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
18 changes: 6 additions & 12 deletions docs/csharp/misc/cs0077.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ However, using [pattern matching](../fundamentals/functional/pattern-matching.md
```csharp
// CS0077.cs
using System;

class C
{
}


struct S
{
}
Expand All @@ -34,17 +30,15 @@ class M
{
public static void Main()
{
object o1, o2;
C c;
object o;
S s;

o = new S();

o1 = new C();
o2 = new S();

s = o2 as S; // CS0077, S is not a reference type
s = o as S; // CS0077, S is not a reference type

// Use pattern matching instead of as
if (o2 is S sValue)
if (o is S sValue)
{
s = sValue;
}
Expand Down
Loading