Convert back to a String using the String constructor that takes a Unicode character array. : String « Data Type « Visual C++ .NET






Convert back to a String using the String constructor that takes a Unicode character array.

 

#include "stdafx.h"
using namespace System;

int main()
{
   String^ str = "A quick sly fox jumped over the lazy brown dog.";

   array<Char>^ character_array = str->ToCharArray();

   Console::WriteLine( str);

   for (int i = 0; i < character_array->Length; i++)
   {
      if ( character_array[i] >= L'a' && character_array[i] <= 'z')
      {
        character_array[i] -= (L'a' - L'A');
      }
   }

   str = gcnew String(character_array);

   Console::WriteLine( str);
}

   
  








Related examples in the same category

1.String Literals
2.Create a String
3.Create some strings
4.Reverse a string
5.Output a string
6.Insert into a string
7.Remove text from strings
8.Create a copy, then concatenate new text
9.Replace stuff in a concatenated string
10.Compare two strings with String::Compare
11.Use static method String::Compare to compare two strings
12.Compare strings for equality with ==
13.Compare strings for equality with String::Equals
14.Compare strings for equality with String::ReferenceEquals
15.Using string for each loop to output chars
16.String operator plus
17.Convert String to char array
18.Convert String to char pointer
19.Convert text read from stdin to uppercase and write to stdout