【发布时间】:2020-01-16 21:16:18
【问题描述】:
我想知道是否有可能让该方法强制您使用设置列表中的某些内容。
我想做什么的例子:
public static List<string> languages = new List<string>() { "cs", "de", "en", "es", "fr", "it", "jp", "nl", "ru", "zh" };
// Im trying to enforce the translate() method to make the parameter "transTo" one of the strings in the
// list. I might be dumb and new but is this possible in c#?
public static void Translate(string path, string key, string transTo)
{
...
}
对堆栈溢出很陌生,告诉我我做错了什么:I
【问题讨论】:
-
languages列表的内容是在编译时还是运行时确定的?例如。是否可以将语言添加到列表中,从而使新的语言代码有效?
标签: c# list methods parameters