Initializes a new instance of the String class to the value indicated by an array of Unicode characters.
[Visual Basic]
Public Sub New( _
ByVal value() As Char _
)
[C#]
public String(
char[] value
);
[C++]
public: String(
__wchar_t value __gc[]
);
[JScript]
public function String(
value : Char[]
);
Parameters
- value
- An array of Unicode characters.
Remarks
If value is a null reference (Nothing in Visual Basic) or contains no element, an Empty instance is initialized.
Example
[C#, C++] The following simple code example demonstrates how you can create an instance of the String class with this constructor.
[C#]
// Unicode Mathematical operators
char [] charArr1 = {'\u2200','\u2202','\u200F','\u2205'};
String szMathSymbols = new String(charArr1);
// Unicode Letterlike Symbols
char [] charArr2 = {'\u2111','\u2118','\u2122','\u2126'};
String szLetterLike = new String (charArr2);
// Compare Strings - the result is false
Console.WriteLine("The Strings are equal? " +
(String.Compare(szMathSymbols, szLetterLike)==0?"true":"false") );
[C++]
// Unicode Mathematical operators
wchar_t charArray1 [4] = {L'\x2200',L'\x2202',L'\x200F',L'\x2205'};
wchar_t* lptstr1 = &charArray1[0];
String* wszMathSymbols = new String(lptstr1);
// Unicode Letterlike Symbols
wchar_t charArray2 [4] = {L'\x2111',L'\x2118',L'\x2122',L'\x2126'};
wchar_t* lptstr2 = &charArray2[0];
String* wszLetterLike = new String (lptstr2);
// Compare Strings - the result is false
Console::WriteLine(String::Concat(L"The Strings are equal? ",
(0 == String::Compare(wszLetterLike,wszMathSymbols)?L"TRUE":L"FALSE") ));
[Visual Basic, JScript] No example is available for Visual Basic or JScript. To view a C# or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard
See Also
String Class | String Members | System Namespace | String Constructor Overload List | Char