Use this
myString = Convert::ToChar(MyVariable0);
myString += Convert::ToChar(MyVariable1);
myString += Convert::ToChar(MyVariable2);
myString = Convert::ToChar(MyVariable0);
myString += Convert::ToChar(MyVariable1);
myString += Convert::ToChar(MyVariable2);
Different ways to create string arrays:
array ^myArray = gcnew array (10);
//or
array ^myArray;
myArray = gcnew array (10);
//or
array ^myArray = {"channel8", "channel9", "technet" , "channel10", "msdn"};
array<Byte> ^RxData = gcnew array<Byte>(2);
RxData[0] = 'A';
RxData[0] = 'B';
String ^sTemp;
(more...)
String ^sTemp;
array<Byte> ^TxData;
sTemp = "Hello";
TxData = System::Text::Encoding::UTF8->GetBytes(sTemp);
(more...)
using namespace System::Text;
Encoding ^Unicode1 = Encoding::Unicode;
array<Byte> ^UnicodeBytes = Unicode1->GetBytes("1234"); //Produces: 0x31,0x00,0x32,0x00,0x33,0x00,0x34,0x00
MyString = String::Format("{0:D}", MyVariable);
MyString = String::Format("{0:D6}", MyVariable); //D6 formats value to 6 digits, inserting leading zero's if necessary
When you want to manipulate and edit strings use StringBuilder rather than String.
StringBuilder^ myString = gcnew StringBuilder("Hello World", 30);
//Start off with 30 character capacity (will auto grow as needed)
The string type is a library type and is actaully an array of char or wchar_t. The last character in a string is always null.
The library takes care of managing the memory associated with storing the elements. As well as being less powerful, C-style strings are the root cause of many many security problems, so always use the string library instead.
ConvertedString = System::Web::HttpUtility::UrlEncode(SomeString);
In countries such as Germany they use commas as decimal points (e.g. -0,136222). So if your program is converting a string like this: (more…)
sTemp = "ABCDEF";
sTemp = sTemp->Substring(1, 1); //Get a single character from the source string
Result = Result->Remove(LICENSER_PRODUCT_ID_1_INDEX, 1); //Remove the character to be replaced in the destination string
Result = Result->Insert(LICENSER_PRODUCT_ID_1_INDEX, sTemp); //Add the character
sTemp += "\r\n" //Add a newline
String ^sTemp = = "\x7"; // ‘\x’ means ‘0x’ and the 1 of 2 digits that follow are a hex value for the character requried
(more...)