I am seeing a difference between Elements C# and Microsoft’s C# around the is operator.
This program:
namespace Test
{
class Person
{
}
static class Program
{
public static Int32 Main(string[] args)
{
var p = new Person();
if (p is null)
{
Console.WriteLine("Oh dear");
}
}
}
}
Compiles on Visual Studio 2019 on the Mac but fails to compile in Fire (macOS Island console app). The error I get in Fire is:
The example I provided is contrived. Where I’ve used it before is to check that an object passed as a constructor argument isn’t null. I don’t mind using ==null instead of is null but the VC# compiler accepts both. I think the edge case that the is operator avoids issues if you’ve also overridden the == method for a class.
It has some initially odd-seeming side-effects, but far from crazy imho. And ironically this seems to fit with C# increasingly embracing English-like syntax, more commonly associated with … Pascal (see also: not, and + or in C# 9).
I guess they’ve finally run out of hieroglyphs to construct out of the standard symbols on a Roman character-set keyboard.