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
public const int CharSize;
public: const int CharSize;
public var CharSize : int;


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


[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

using System;
using System.Text;

class UnicodeEncodingExample {
    public static void Main() {
            "Unicode character size: {0} bytes",

#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.


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