TechNet
Export (0) Print
Expand All

Enum.Equals Method (Object)

 

Returns a value indicating whether this instance is equal to a specified object.

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

override Equals : 
        obj:Object -> bool

Parameters

obj
Type: System.Object

An object to compare with this instance, or null.

Return Value

Type: System.Boolean

true if obj is an enumeration value of the same type and with the same underlying value as this instance; otherwise, false.

The Enum.Equals(Object) method overrides ValueType.Equals(Object) to define how enumeration members are evaluated for equality.

The following example illustrates the use of the Equals method.

No code example is currently available or this language may not be supported.

The following example defines two enumeration types, SledDog and WorkDog. The SledDog enumeration has two members, SledDog.AlaskanMalamute and SledDog.Malamute, that have the same underlying value. The call to the Equals method indicates that these values are equal because their underlying values are the same. The SledDog.Malamute and WorkDog.Newfoundland members have the same underlying value, although they represent different enumeration types. A call to the Equals method indicates that these values are not equal.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft