有这个类:枚举
public static class Command
{
public const string SET_STB_MEDIA_CTRL = "SET STB MEDIA CTRL ";
public static string ECHO = "ECHO";
public static string SET_CHANNEL = "SET CHANNEL ";
public static string GET_VOLUMN = "GET VOLUMN";
public static string GET_MAX_VOLUMN = "GET MAX VOLUMN ";
public string SET_STB_MEDIA_LIST = "SET STB MEDIA LIST ";
}
则:
public static class MultimediaConstants
{
public const string VIDEO = "video";
public const string AUDIO = "audio";
public const string PHOTO = "photo";
public const string ALL = "all";
public const string BACKGROUND_MUSIC = "background_music";
public const string TV = "tv";
public const string ACTION_PLAY = "play";
}
的一点是,我想有这样的事情:
public static string SET_STB_MEDIA_CTRL (MultimediaConstants type, MultimediaConstants action)
{
return Command.SET_STB_MEDIA_CTRL + "type:" + type + "action:" + action;
}
所以此方法的结果应为:
SET STB MEDIA CTRL type:tv action:play
方法的调用将是:
SET_STB_MEDIA_CTRL (MultimediaConstants.TV, MultimediaConstants.ACTION_PLAY);
因为无法创建静态类的实例,所以无法请求将静态类的实例作为方法参数 – Sehnsucht
这些arent枚举。这些是类。你可以使用'enum'关键字而不是class来创建枚举。那么你可以使用你想要的值。 –
@Sehnsucht这就是为什么他想要'Enum of strings',就像java可以让你做 –