本文介绍了为什么不String类实现IEnumerable<烧焦>便携式图书馆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个PCL项目面向.NET Framework 4的和Silverlight 5(我使用Visual Studio 2010中,不便于携带项目模板的扩展从Visual Studio 2012,如果该事项)。我试图扭转使用 System.Linq.Enumerable.Reverse℃的字符串; TSource>()扩展方法,但它不工作,因为编译器认为 System.String 不执行的IEnumerable<焦炭>

I've created a PCL project that targets .NET Framework 4 and Silverlight 5 (I use an extension for Visual Studio 2010, not portable project template from Visual Studio 2012, if that matters).I am trying to reverse a string using System.Linq.Enumerable.Reverse<TSource>() extension method, but it doesn't work because compiler thinks that System.String doesn't implement IEnumerable<char>.

推荐答案

便携式类库必须限制自己可用的一切承诺支持目标平台的类和方法。最大的麻烦制造者这里是WinRT中,CLR的具有WinRT的类型映射到托管类型语言投影。不支持的投影System.String方法都记录在这个答案。的GetEnumerator()就是其中之一。

The Portable Class Libraries must restrict itself to the classes and methods that are available on all the target platforms it promises to support. The biggest trouble-maker here is WinRT, the CLR has a language projection that maps WinRT types to managed types. The System.String methods not supported by the projection are documented in this answer. GetEnumerator() is one of them.

这篇关于为什么不String类实现IEnumerable&LT;烧焦&GT;便携式图书馆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-14 23:44