This documentation is archived and is not being maintained.

UnicodeEncoding.CharSize Field

Represents the Unicode version 2.0 character size in bytes.

[Visual Basic]
Public Const CharSize As Integer
[C#]
public const int CharSize;
[C++]
public: const int CharSize;
[JScript]
public var CharSize : int;

Remarks

The value of this field is a 32-bit signed constant, with a value of two.

Example

[Visual Basic, C#, C++] The following example demonstrates how to return the value of CharSize and display it to the console.

[Visual Basic] 
Imports System
Imports System.Text

Class UnicodeEncodingExample
    
    Public Shared Sub Main()
        Console.WriteLine("Unicode character size: {0} bytes", UnicodeEncoding.CharSize)
    End Sub 'Main
End Class 'UnicodeEncodingExample

[C#] 
using System;
using System.Text;

class UnicodeEncodingExample {
    public static void Main() {
        Console.WriteLine(
            "Unicode character size: {0} bytes",
            UnicodeEncoding.CharSize
        );
    }
}

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Text;

int main()
{
   Console::WriteLine(S"Unicode character size: {0} bytes", __box(UnicodeEncoding::CharSize));
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter 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

See Also

UnicodeEncoding Class | UnicodeEncoding Members | System.Text Namespace

Show: