Version Used:
Visual Studio 2017
C#7.1
.NET Framework 4.7
Steps to Reproduce:
C#
namespace Test
{
static unsafe class Program
{
static void Main()
{
object obj = new byte*[10];
bool b = obj is byte*[];
}
}
}
Expected Behavior:
Compile success.
Actual Behavior:
Program.cs(8,20,8,24): error CS1525: Invalid expression term 'byte'
Program.cs(8,25,8,26): error CS1525: Invalid expression term '['
Program.cs(8,26,8,27): error CS0443: Syntax error; value expected
The is operator doesn't work with pointers. I believe that limitation is inherited from the CLR isinst opcode not being able to distinguish between different pointer types.
The type byte*[] isn't a pointer type, it's actually an array type.
And that code can compiled by older csc.exe compilers.
So I think maybe that's a bug, not feature.
Most helpful comment
The
isoperator doesn't work with pointers. I believe that limitation is inherited from the CLRisinstopcode not being able to distinguish between different pointer types.