I know this exact question has been asked, but the solution posted there doesn’t seem to work for me. Here’s the code I’m trying:
namespace ConsoleApplication5
{
class Program
{
enum Tile { Empty, White, Black };
using Board = Tile[8,8];
And the error I get:
Invalid token ‘using’ in class, struct, or interface member declaration
It seems the “using” clause must be moved outside the Program class, but my Tile enum doesn’t exist there. So how am I supposed to do this?
It looks like you’re trying to use a name to represent a specific way of instantiating a
Tile[,]array.Why not just declare a method that does this?
Another option, though I’d consider this a little bit bizarre (not to mention hacky), would be to define a
Boardtype with an implicit operator to convert toTile[,], as follows:This would actually allow you to do this: