Question : Convert UCHAR[] to System::string

I have an array of UCHAR's that is returned from a SCSI command (recorder information). I need to convert these to a System::String. Is there an easy way to accomplish this?

UCHAR VendorInformation[8];
// Contents would be the following
VendorInformation[0];
VendorInformation[0]  //{ p
VendorInformation[1]; //{ l
VendorInformation[2]; //{ e
VendorInformation[3]; //{ x
VendorInformation[4]; //{t
VendorInformation[5]; //{o
...

I want to take this information and store it in a managed string.


Answer : Convert UCHAR[] to System::string

Sorry, you need to typecast the array to char* to pass it in to the string's constructor.
1:
2:
3:
4:
5:
6:
7:
8:
9:
int main(array ^args)
{
	UCHAR VendorInformation[] = {'a', 'b', 'c'}; 
	System::String ^VendorInfoString = gcnew System::String((char*)VendorInformation); 
	Console::WriteLine(VendorInfoString); 
	Console::ReadKey(); 
    return 0; 
 
}
Random Solutions  
 
programming4us programming4us