这一行:
enum commandLine : int
应将以下枚举定义为int但不是,但不是。 这有什么不对?
using System;
enum commandLine : int
{
DRIVELETTER = 0,
URL
}
namespace not_int
{
class Program
{
static void Main(string[] args)
{
String driveLetter;
driveLetter = args[commandLine.DRIVELETTER]; // Cannot implicitly convert type 'commandLine' to 'int' ... Yes You Can!
driveLetter = args[(int)commandLine.DRIVELETTER]; // This works but feels like talking to a grown-up like he was a child:
// You see, here we have an integer but to you it looks like an integer of a different type. Here I tell you it's an integer of the type you want, like your candies ...
// This way you are happy like with your friday candy ...
}
}
}