简体   繁体   English

metro c#中缺少String.Intern()方法

[英]String.Intern() method missing in metro c#

How to get string intern method in Metro c#. 如何在Metro c#中获取字符串实习方法。 if not found in windows 8 c#, is there any equivalent method to maintain system's reference to the specified String. 如果在Windows 8 c#中找不到,是否有任何等效的方法来维护系统对指定String的引用。

This is an inevitable side-effect of the language projection built into the CLR that enables the ".NET for Metro style apps" api. 这是CLR中内置语言投影不可避免的副作用,它支持“.NET for Metro风格应用程序”API。 That projection maps a string that was obtained from a WinRT api call to System.String. 该投影将从WinRT api调用获得的字符串映射到System.String。 The underlying string is not a managed string at all and doesn't live on the garbage collected heap. 底层字符串根本不是托管字符串,并不存在于垃圾收集堆上。 It is an HSTRING. 这是一个HSTRING。 The language projection makes it behave like a System.String 语言投影使其行为类似于System.String

Accordingly, in that api, the String class doesn't have the methods that are very specific to managed strings. 因此,在该api中,String类没有特定于托管字符串的方法。 Like Intern() and IsInterned(), that can only work for managed strings. 像Intern()和IsInterned()一样,它只适用于托管字符串。 Copy, Clone and GetEnumerator are awol too. 复制,克隆和GetEnumerator也很棒。 There's no workaround for this, access to the managed String class in mscorlib is entirely blocked by the reference assemblies, it gets type forwarded to System.Runtime.dll. 没有解决方法,在mscorlib中对托管String类的访问完全被引用程序集阻止,它将类型转发到System.Runtime.dll。 You'll have to make it work without that method. 如果没有这种方法,你必须让它工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM