【发布时间】:2017-02-22 21:41:50
【问题描述】:
我正在使用 WPF(C#) 进行编程。我用这个函数填充了ComboBox:
public static void PopulateComboBox(ComboBox cmb, Type type)
{
foreach (string name in Enum.GetNames(type))
{
cmb.Items.Add(name);
}
}
现在我需要这样的方法(如下图所示)来获取any enum 作为输出:
public static enum PopulateComboBox(ComboBox cmb, string nameOfEnum, Type type)
{
}
这样的函数怎么写?
【问题讨论】:
-
你的意思是
public static Enum...?不知道你在问什么,你的问题是什么? -
您不能返回
enum。我认为你的意思是返回 Enum 类型的东西。 -
List<string> names = new List<string>();的目的是什么? -
@KernelMode 感谢您的评论。我忘了删除这一行。
标签: c# types enums enumeration