Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9208653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:39:45+00:00 2026-06-18T00:39:45+00:00

How do I convert a fixed byte array to a String in managed c++/cli

  • 0

How do I convert a fixed byte array to a String in managed c++/cli ?
For example I have the following Byte array.

Byte byte_data[5];
byte_data[0]='a';
byte_data[1]='b';
byte_data[2]='c';
byte_data[3]='d';
byte_data[4]='e';

I have tried the following code
String ^mytext=System::Text::UTF8Encoding::UTF8->GetString(byte_data);

I get the following error:
error C2664: 'System::String ^System::Text::Encoding::GetString(cli::array<Type,dimension> ^)' : cannot convert parameter 1 from 'unsigned char [5]' to 'cli::array<Type,dimension> ^'

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:39:47+00:00Added an answer on June 18, 2026 at 12:39 am

    Arm yourself with some knowledge about casting between pointers to signed and unsigned types and then you should be set to use String::String(SByte*, Int32, Int32). It might also pay to read the Remarks on the page, specifically around encoding.

    I’ve reproduced the sample from the page here:

    // Null terminated ASCII characters in a simple char array 
    char charArray3[4] = {0x41,0x42,0x43,0x00};
    char * pstr3 =  &charArray3[ 0 ];
    String^ szAsciiUpper = gcnew String( pstr3 );
    char charArray4[4] = {0x61,0x62,0x63,0x00};
    char * pstr4 =  &charArray4[ 0 ];
    String^ szAsciiLower = gcnew String( pstr4,0,sizeof(charArray4) );
    
    // Prints "ABC abc"
    Console::WriteLine( String::Concat( szAsciiUpper,  " ", szAsciiLower ) );
    
    // Compare Strings - the result is true
    Console::WriteLine( String::Concat(  "The Strings are equal when capitalized ? ", (0 == String::Compare( szAsciiUpper->ToUpper(), szAsciiLower->ToUpper() ) ? (String^)"TRUE" :  "FALSE") ) );
    
    // This is the effective equivalent of another Compare method, which ignores case
    Console::WriteLine( String::Concat(  "The Strings are equal when capitalized ? ", (0 == String::Compare( szAsciiUpper, szAsciiLower, true ) ? (String^)"TRUE" :  "FALSE") ) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this json string: {17:{31:{price:5,oldPrice:5,priceValue:5.0000,type:fixed,excludeTax:5,includeTax:5},29:{price:8,oldPrice:8,priceValue:8.0000,type:fixed,excludeTax:8,includeTax:8},30:{price:10,oldPrice:10,priceValue:10.0000,type:fixed,excludeTax:10,includeTax:10}},12:{price:0,oldPrice:0,priceValue:0.0000,type:fixed,excludeTax:0,includeTax:0},11:{price:0,oldPrice:0,priceValue:0.0000,type:fixed,excludeTax:0,includeTax:0}} How can I convert this to an array
Is there a way to convert a byte array to string other than using
I'm using this code to convert a hex string with fixed size 32 to
What's the best way to convert a fixed byte or char[100] to a managed
I have been trying for hours to convert this. I have tried looping through
I tried to convert some C code to Java, but it is working slightly
I need some C# code to convert a double to a byte*. I know
I want to convert bytes in to String. I have one android application and
I have a byte array which I would like to access by Int32 pointer
I need to convert in procedure from string to decimal with fixed decimal separator

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.