C# UnicodeEncoding GetByteCount(String)

Description

UnicodeEncoding GetByteCount(String) Calculates the number of bytes produced by encoding the characters in the specified String.

Syntax

UnicodeEncoding.GetByteCount(String) has the following syntax.


public override int GetByteCount(
  string s
)

Parameters

UnicodeEncoding.GetByteCount(String) has the following parameters.

  • s - The String containing the set of characters to encode.

Returns

UnicodeEncoding.GetByteCount(String) method returns The number of bytes produced by encoding the specified characters.

Example


using System;// w  w w  .j  a va 2s.  c o m
using System.Text;

class UnicodeEncodingExample {
    public static void Main() {
        String chars = "Unicode Encoding Example";

        UnicodeEncoding Unicode = new UnicodeEncoding();
        int byteCount = Unicode.GetByteCount(chars);
        Console.WriteLine(byteCount);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding