本文介绍了混合字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何混合使用std :: wstring和.NET String?我发现.NET

文件令人沮丧。


Graeme

How can I mix std::wstring and .NET String? I''m finding the .NET
documentation frustrating.

Graeme

推荐答案



你可以。但是为什么?


问候

Jochen

You can. But why?

Greetings
Jochen




遇到两个问题:


(1)在wchar_t *和std :: wstring之间转换

解决方案:wstring构造函数和c_str()成员


(2)在wchar_t *和System :: String之间转换^

解决方案:PtrToStringChars和Marshal :: PtrToStringUni

Break into two problems:

(1) Convert between wchar_t* and std::wstring
Solution: wstring constructor and c_str() member

(2) Convert between wchar_t* and System::String^
Solution: PtrToStringChars and Marshal::PtrToStringUni





你可以。但为什么?


You can. But why?



因为.NET是世界上很小的一部分?因为标准兼容的现有C ++代码有很多

,因此使用

std :: basic_string进行字符串处理,您可能希望从

..NET?

Because .NET is one very small portion of the world? Because there is a lot
of existing C++ code that is standard compliant, therefore using
std::basic_string for string handling, which you might want to call from
..NET?



这篇关于混合字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 01:18