Remove the unused variables after working on CS0077 (#43368)
This commit is contained in:
Родитель
a96b3eb7b4
Коммит
c47a4a83c5
|
@ -21,11 +21,7 @@ However, using [pattern matching](../fundamentals/functional/pattern-matching.md
|
|||
```csharp
|
||||
// CS0077.cs
|
||||
using System;
|
||||
|
||||
class C
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
struct S
|
||||
{
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче