gpt4 book ai didi

c# - MonoTouch.Dialog:Add(System.Collections.Generic.IEnumerable) 已过时 - 我必须更改某些内容吗?

转载 作者:太空宇宙 更新时间:2023-11-03 13:57:35 26 4
gpt4 key购买 nike

下面的代码给出了警告:

Warning CS0618: MonoTouch.Dialog.Section.Add(System.Collections.Generic.IEnumerable<MonoTouch.Dialog.Element>)'
is obsolete:
Please use AddAll since this version will not work in future versions of MonoTouch when we introduce 4.0 covariance'

这是代码。我不叫Add()明确地。 aMyReviewElementsList<Element>()我正在使用便利的初始值设定项。我是否必须调整我的代码(这将使整个便利无法使用),或者 MT.Dialog 内部是否需要更改?

...
List<Element> aMyReviewElements = new List<Element>();

...
new Section("My Reviews")
{
aMyReviewElements
},
...

最佳答案

在 C# 中,集合初始化器需要一个名为 Add 的方法,它在 MD 中指的是 this method (注意 Obsolete 属性)。

看起来 MD 人员已经引入了一个新的 Add 方法 LINQ support .所以我的建议是注意警告并更新您的代码以使用 LINQ,例如

List<Element> aMyReviewElements = new List<Element>();
...
new Section("My Reviews")
{
from e in aMyReviewElement
select e
};

关于c# - MonoTouch.Dialog:Add(System.Collections.Generic.IEnumerable<MonoTouch.Dialog.Element>) 已过时 - 我必须更改某些内容吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11646540/

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