I tried using a collection expression when setting the storage prefixes, but the Neo compiler does not support that properly, thus throwing a "Specified cast invalid" at runtime.
// Does NOT work:
private static readonly byte[] TreeByteLengthPrefix = [0x01, 0x03];
// Works:
private static readonly byte[] TreeByteLengthPrefix = new byte[] {0x01, 0x03};
I think it should either be supported or give a warning/error at compile time, as it was frustrating to debug.
PS: While looking in the C# Language Specification Support issue https://github.com/neo-project/neo-devpack-dotnet/issues/819 , I could not find the collection expression support listed. I think collection expressions were introduced in C# 12.
I tried using a collection expression when setting the storage prefixes, but the Neo compiler does not support that properly, thus throwing a "Specified cast invalid" at runtime.
I think it should either be supported or give a warning/error at compile time, as it was frustrating to debug.
PS: While looking in the C# Language Specification Support issue https://github.com/neo-project/neo-devpack-dotnet/issues/819 , I could not find the collection expression support listed. I think collection expressions were introduced in C# 12.