gpt4 book ai didi

c# - 错误 95 'System.Array' 不包含 'FindIndex' 的定义

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

我正在将我现有的 Windows Phone 8 应用程序转换为 WP 7.1。但是我遇到了一个错误

'System.Array' does not contain a definition for 'FindIndex'

在这一行。我错过了什么?

index = Array.FindIndex(AnswerLevelArr, s => s.Contains(CurrentFileName));

最佳答案

Array.FindIndex Method (T[], Predicate)在 Windows Phone 7.1 中不受支持。

Version Information

Windows Phone OS
Supported in: 8.0

相反,您可以使用 Linq(确保将 using System.Linq; 添加到文件顶部):

index = AnswerLevelArr
.Select((i, position) => new { Item = i, IndexOf = position })
.First(s => s.Item.Contains(CurrentFileName)).IndexOf;

或:

int index=0;
var result = AnswerLevelArr.SkipWhile((s, ind) =>
{
if (!s.Contains(CurrentFileName))
{
index++;
return false;
}
else
{
return true;
}
}).First();

关于c# - 错误 95 'System.Array' 不包含 'FindIndex' 的定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15266079/

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