You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#nullable enable
using System;
namespace Demo
{
public interface ITest
{
public bool TryGet<T>(out T? result) where T : notnull;
}
public abstract class MyAbstractClass : ITest
{
public abstract bool TryGet<T>(out T? result) where T : notnull;
}
public class MyDerivedClass : MyAbstractClass
{
public override bool TryGet<T>(out T result)
{
throw new Exception("");
}
}
}
public class Program
{
public static void Main()
{
Console.WriteLine("Hello World");
}
}
This fails:
#nullable enable
using System;
namespace Demo
{
public interface ITest
{
public bool TryGet<T>(out T? result) where T : notnull;
}
public abstract class MyAbstractClass : ITest
{
public abstract bool TryGet<T>(out T? result) where T : notnull;
}
public class MyDerivedClass : MyAbstractClass
{
public override bool TryGet<T>(out T? result)
{
throw new Exception("");
}
}
}
public class Program
{
public static void Main()
{
Console.WriteLine("Hello World");
}
}
public override bool TryGet<T>(out T result) signature, the one the compiler is happy to accept, contradicts both inherited definitions while it rejects public override bool TryGet<T>(out T? result) which is exactly the same as in parents.
The text was updated successfully, but these errors were encountered:
This compiles:
This fails:
public override bool TryGet<T>(out T result)
signature, the one the compiler is happy to accept, contradicts both inherited definitions while it rejectspublic override bool TryGet<T>(out T? result)
which is exactly the same as in parents.The text was updated successfully, but these errors were encountered: