Files
WoofWare.PawPrint/WoofWare.PawPrint.Test/sourcesPure/IsinstFailed.cs
Smaug123 277f303431 WIP
2025-06-27 12:09:15 +01:00

26 lines
518 B
C#

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 };
// Cast to object first to bypass compile-time checking
object obj = sparrow;
// This should fail at runtime and return null (not throw)
Fish fish = obj as Fish;
return fish == null ? 42 : 0;
}
}