2

The piece of code below gives me the warning:

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'

This is the code. I don't call Add() explicitly. aMyReviewElements is a List<Element>() and I'm using the convenience initializers. Do I have to adjust my code (that will make the whole convenience unusable), or does MT.Dialog internally need a change?

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

...
new Section("My Reviews")
{
  aMyReviewElements
},
...
Krumelur
  • 32,180
  • 27
  • 124
  • 263

1 Answers1

1

In C#, collection initializers require a method called Add which in MD is referring to this method (note the Obsolete attribute).

It looks as though the MD guys have introduced a new Add method with LINQ support. So my advice is heed the warning and update your code to use LINQ e.g.

List<Element> aMyReviewElements = new List<Element>();
...
new Section("My Reviews")
{
    from e in aMyReviewElement
    select e
};
James
  • 80,725
  • 18
  • 167
  • 237
  • Hm @James, seemed like a great answer, but in my code there is already a `from ... select ..` construct used in the Section initializer. However I still get the same compiler warning about being obsolete (Xamarin Studio v. 4.2 compiled to iOS 7). Also your links to the Xamarin code were made out of date by Xamarin updates :(. Any idea how to fix this issue now? – Bart Nov 15 '13 at 16:26