Skip to content

Commit d779b5b

Browse files
volkan-yazilimBillWagner
authored andcommitted
Update Program.cs (#500)
1 parent fd8785d commit d779b5b

File tree

1 file changed

+2
-4
lines changed
  • snippets/csharp/how-to/safelycast/patternmatching

1 file changed

+2
-4
lines changed

snippets/csharp/how-to/safelycast/patternmatching/Program.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ static void Main(string[] args)
2525

2626
TestForMammals(g);
2727

28-
// Use the as operator to test
29-
// an incompatible type.
3028
SuperNova sn = new SuperNova();
3129
TestForMammals(sn);
3230
}
3331

3432
static void FeedMammals(Animal a)
3533
{
36-
// Use the is operator to verify the type.
34+
// Use the is operator to verify the type
3735
// before performing a cast.
3836
if (a is Mammal m)
3937
{
@@ -43,7 +41,7 @@ static void FeedMammals(Animal a)
4341

4442
static void TestForMammals(object o)
4543
{
46-
// Use the as operator and test for null
44+
// Alternatively, use the as operator and test for null
4745
// before referencing the variable.
4846
if (o is Mammal m)
4947
{

0 commit comments

Comments
 (0)