gpt4 book ai didi

c# - 将枚举转换为 List 的一般方法

转载 作者:太空狗 更新时间:2023-10-29 22:23:01 24 4
gpt4 key购买 nike

<分区>

这是一个“奇怪”的问题:

是否可以创建一个方法,在其中将任何枚举转换为列表。这是我目前的想法草稿。

public class EnumTypes
{
public enum Enum1
{
Enum1_Choice1 = 1,
Enum1_Choice2 = 2
}

public enum Enum2
{
Enum2_Choice1 = 1,
Enum2_Choice2 = 2
}

public List<string> ExportEnumToList(<enum choice> enumName)
{
List<string> enumList = new List<string>();
//TODO: Do something here which I don't know how to do it.
return enumList;
}
}

只是好奇这是否可能以及如何去做。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com