0

我想知道如何将“PWSTR”转换为“System::String^”

   My code snippet follows here...

   array<System::String^>^ nsRecords;

   try
   {
     nsRecordCount = dns.query(ipAddressString);
     nsRecords = gcnew array<System::String^>(nsRecordCount);

     for(int nsRecord = 0; nsRecord < nsRecordCount; nsRecord++)
     {
   DNS_PTR_DATA record  = dns.getNth(nsRecord);
 // below line of code causing error C2440: '=' :  
     //cannot convert from 'PWSTR' to 'System::String ^'
       nsRecords[nsRecord] = record.pNameHost; 
     }

   }

我感谢您的帮助!

谢谢, 拉马尼

4

1 回答 1

1

gcnew String()应该足够了。顺便说一句,这是一个 C++/CLI 问题,而不是 c++ 11。

于 2013-05-15T18:12:07.100 回答