gpt4 book ai didi

c# - 在 C# 中初始化 IEnumerable

转载 作者:IT王子 更新时间:2023-10-29 03:35:39 24 4
gpt4 key购买 nike

我有这个对象:

IEnumerable<string> m_oEnum = null;

我想初始化它。尝试过

IEnumerable<string> m_oEnum = new IEnumerable<string>() { "1", "2", "3"};

但它说“IEnumerable 不包含添加字符串的方法。知道吗?谢谢

最佳答案

好的,添加您可能正在寻找的答案

IEnumerable<string> m_oEnum = Enumerable.Empty<string>();

IEnumerable<string> m_oEnum = new string[]{};

关于c# - 在 C# 中初始化 IEnumerable<string>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6573069/

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