gpt4 book ai didi

c# - 未分配 'out'参数错误如何解决?

转载 作者:太空狗 更新时间:2023-10-29 21:08:43 26 4
gpt4 key购买 nike

<分区>

我正在尝试计算给定路径的所有子文件夹中的文件总数。我正在使用递归函数调用。可能是什么原因?

代码:

int iCount =0; 
getFileCount(_dirPath, out iCount);

private void getFileCount(string _path, out int iCount )
{
try
{
// gives error :Use of unassigned out parameter 'iCount' RED Underline
iCount += Directory.GetFiles(_path).Length;

foreach (string _dirPath in Directory.GetDirectories(_path))
getFileCount(_dirPath, out iCount);
}
catch { }
}

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