Implement Castclass

This commit is contained in:
Smaug123
2025-06-27 11:41:41 +01:00
parent 5cf0789439
commit 1ebcd0b4f5
42 changed files with 856 additions and 132 deletions

View File

@@ -0,0 +1,22 @@
public class Program
{
public class Bird
{
public bool CanFly { get; set; }
}
public class Fish
{
public bool CanSwim { get; set; }
}
public static int Main(string[] args)
{
Bird sparrow = new Bird { CanFly = true };
// This should fail and return null (not throw)
Fish fish = sparrow as Fish;
return fish == null ? 42 : 0;
}
}