gpt4 book ai didi

c# - 类型 'System.Collections.Generic.IEnumerable ' 无法隐式转换为 'string []'

转载 作者:太空宇宙 更新时间:2023-11-03 21:29:22 24 4
gpt4 key购买 nike

我有一个问题,我想你可以帮助我,我有这段代码:

string[] A1 = 
Directory
.GetFileSystemEntries(textbox2_f2.Text, "*", SearchOption.AllDirectories)
.Select(System.IO.Path.GetFileName);

for (int i1 = 0; i1 < A1.Length; i1++)
listbox_2f.Items.Add(A1[i1]);

这里是错误:

The type 'System.Collections.Generic.IEnumerable ' can not be implicitly converted to 'string []'. There is already an explicit conversion exists.

我该如何解决这个问题?

最佳答案

尝试:

Directory.GetFileSystemEntries(textbox2_f2.Text, "*", SearchOption.AllDirectories)
.Select(System.IO.Path.GetFileName)
.ToArray()

关于c# - 类型 'System.Collections.Generic.IEnumerable <string>' 无法隐式转换为 'string []',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25042274/

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