[置顶] 【Unity3D游戏开发】System.Collections.Generic.ICollection`1.CopyTo 错误 (二三)

使用Unity,编辑器模式没有问题,iOS上报错误

System.Collections.Generic.ICollection`1.CopyTo


错误位置:

string[] receipts = PlayerPrefsEx.GetStringArray("unfinished_iap_receipt");
List<string> unFinIAPReceipts = new List<string>(receipts);

出错原因:

Most of Linq extension methods from Linq for Collections are not working with IEnumerables on iOS since they require AOT runtime compiler which is not supported.

However there is a Linq for iOS library on Asset Store that is similar to Linq but doesn't require a runtime compiler. So you can use it on iOS and ToArray() method will work with this library.


iOS真机上对使用C#的Linq有限制 


List<string> ls = new List<string>(receipts);



解决办法:

使用for循环赋值吧,虽然麻烦了点

你可能感兴趣的:(unity,LINQ,IEnumerable,ICollection,copyTo)