Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Encoding.Equals Method (Object)

Determines whether the specified Object is equal to the current instance.

Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)

public override bool Equals (
	Object value
)
public boolean Equals (
	Object value
)
public override function Equals (
	value : Object
) : boolean

Parameters

value

The Object to compare with the current instance.

Return Value

true if value is an instance of Encoding and is equal to the current instance; otherwise, false.

Two instances of Encoding are considered equal if they correspond to the same code page.

The following code example gets two instances of the same encoding (one by codepage and another by name), and checks their equality.

using System;
using System.Text;

public class SamplesEncoding  {

   public static void Main()  {

      // Get a UTF-32 encoding by codepage.
      Encoding e1 = Encoding.GetEncoding( 65005 );

      // Get a UTF-32 encoding by name.
      Encoding e2 = Encoding.GetEncoding( "utf-32" );

      // Check their equality.
      Console.WriteLine( "e1 equals e2? {0}", e1.Equals( e2 ) );

   }

}


/* 
This code produces the following output.

e1 equals e2? True

*/


import System.*;
import System.Text.*;

public class SamplesEncoding
{
    public static void main(String[] args)
    {
        // Get a UTF-32 encoding by codepage.
        Encoding e1 = Encoding.GetEncoding(65005);

        // Get a UTF-32 encoding by name.
        Encoding e2 = Encoding.GetEncoding("utf-32");

        // Check their equality.
        Console.WriteLine("e1 equals e2? {0}",
            System.Convert.ToString(e1.Equals(e2)));
    } //main
} //SamplesEncoding

/* 
This code produces the following output.

e1 equals e2? True

*/


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.