I noticed that the following code seems to compile just fine, when I would've expected multiple errors:
public interface ITest
{
Math Foo(MathF x, ref Console y);
}
Math, MathF, and Console are all static classes - is there any reason why this is valid, or is it just an oddity of the specification/compiler? When attempting to implement the interface, you then receive an error (I guess that means you can make an interface that's impossible to implement, which is kinda cool)
What's more, I can go one worse:
using System;
namespace StaticParams
{
internal class Program
{
static void Main(string[] args)
{
ITest.Bar(null);
}
public interface ITest
{
Math Foo(MathF x, ref Console y);
static void Bar(Math x)
{
Baz(x);
}
static void Baz(Math x)
{
Console.WriteLine("Hello World" + x + "!"); // x is null so we can't do much with it
}
}
}
}
Output:
Hello World!
Tested in VS 2022, using both C# 8.0 + .NET Core 3.1, and C# 10.0 + .NET 6.0.4.