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

String.Intern() method missing in metro c#(Metro c#中缺少String.Intern()方法)
本文介绍了Metro c#中缺少String.Intern()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Metro c# 中获取字符串实习生方法.如果在 windows 8 c# 中找不到,是否有任何等效的方法来维护系统对指定字符串的引用.

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.

推荐答案

这是 CLR 中内置的语言投影不可避免的副作用,它启用了.NET for Metro 风格应用程序"api.该投影将从 WinRT api 调用获得的字符串映射到 System.String.底层字符串根本不是托管字符串,也不存在于垃圾收集堆上.它是一种 HSTRING. 语言投影使它表现得像一个 System.String

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

因此,在该 api 中,String 类没有非常特定于托管字符串的方法.像 Intern() 和 IsInterned() 一样,它只能用于托管字符串.Copy、Clone 和 GetEnumerator 也一样.对此没有解决方法,对 mscorlib 中托管 String 类的访问完全被引用程序集阻止,它将类型转发到 System.Runtime.dll.如果没有这种方法,你必须让它工作.

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.

这篇关于Metro c#中缺少String.Intern()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)