C# Int16 Equals(Object)

Description

Int16 Equals(Object) returns a value indicating whether this instance is equal to a specified object.

Syntax

Int16.Equals(Object) has the following syntax.


public override bool Equals(
  Object obj
)

Parameters

Int16.Equals(Object) has the following parameters.

  • obj - An object to compare to this instance.

Returns

Int16.Equals(Object) method returns true if obj is an instance of Int16 and equals the value of this instance; otherwise, false.

Example

The following code example demonstrates the Equals method.


using System;// ww w . ja va  2 s.co  m

class Sample 
{
    public static void Main() 
    {
        Int16    c1 = -2,    c2 = 2;
        try {
            Console.WriteLine(c1.Equals((Object)c2));
        }catch (Exception e){
            Console.WriteLine(e);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version