Question: As the title implies, I want to compare two objects whose type may be diffrent.

For eg,
I expects 'true' for comparing 1000.0(Decimal) with 1000(Double) .
Similary, it should return true if I compare 10(string) and 10(double) .

I tried to compare using Object.Equals() , but it did NOT work.It return false if two objects have different data types.

```
Dim oldVal As Object  ' assgin some value
Dim newVal As Object  'assgin some value
If Not Object.Equals(oldVal,newVal) Then
  'do something
End If

```

**Edit:**
Could it be possible if I do the below?

```
    1.check the type of oldVal
    2.Covert the type of newVal to oldVal
    3.Compare.

```

Answer: 
Try this:

```
Dim oldVal As Object  'assgin some value
Dim newVal As Object  'assgin some value
Dim b As Boolean = False

If IsNumeric(oldVal) And IsNumeric(newVal) Then
    b = (Val(oldVal) = Val(newVal))
ElseIf IsDate(oldVal) And IsDate(newVal) Then
    b = (CDate(oldVal) = CDate(newVal))
Else
    b = (oldVal.ToString() = newVal.ToString())
End If

If Not b Then
    'do something
End If

```

Or use IIf like this:

```
If Not CBool(IIf(IsNumeric(oldVal) And IsNumeric(newVal), 
                  (Val(oldVal) = Val(newVal)),
                  IIf(IsDate(oldVal) And IsDate(newVal), 
                     (CDate(oldVal) = CDate(newVal)), 
                     (oldVal.ToString() = newVal.ToString())))) Then
    'do something
End If

```
Mixing pears and apples? :)
Equals does equality comparison (the eefault implementation of Equals tests for referential equality). While "=" does identity comparison.

If you need a different behaviour for comparing two objects, then define an Equals method and/or a CompareTo method.

To compare integers with doubles, you have to (implicitly or explicitly) convert one of the two operands. 

```
dim i as integer = 1000
dim d as double = 1000.0

return i = CInt(d)

```