String.Intern() method missing in metro c#

后端 未结 1 837
无人及你
无人及你 2020-12-12 01:10

How to get string intern method in Metro c#. if not found in windows 8 c#, is there any equivalent method to maintain system\'s reference to the specified String.

相关标签:
1条回答
  • 2020-12-12 02:15

    This is an inevitable side-effect of the language projection built into the CLR that enables the ".NET for Metro style apps" api. That projection maps a string that was obtained from a WinRT api call to 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. The language projection makes it behave like a System.String

    Accordingly, in that api, the String class doesn't have the methods that are very specific to managed strings. Like Intern() and IsInterned(), that can only work for managed strings. Copy, Clone and GetEnumerator are awol too. 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. You'll have to make it work without that method.

    0 讨论(0)
提交回复
热议问题