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()方法
基础教程推荐
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
