String.Intern() method missing in metro c#(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()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Metro c#中缺少String.Intern()方法


- 如何用自己压缩一个 IEnumerable 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01