Reputation: 168
I was writing the test case for my code and noticed something unusual about Visual studio. Generally VS indicates the unreachable code but in below code it did not.
Object a = 5;
if(a.Equals(a))
{
Console.WriteLine("Equal");
}
else
{
Console.WriteLine("Not Equal");
}
Is it ever possible that we will fall in else case or it's something visual studio didn't catch?
If so how can we can do it, any examples?
Upvotes: 2
Views: 84
Reputation: 173
From MSDN https://msdn.microsoft.com/en-us/library/bsc2ak47(v=vs.110).aspx:
x.Equals(x) returns true, except in cases that involve floating-point types. See ISO/IEC/IEEE 60559:2011, Information technology -- Microprocessor Systems -- Floating-Point arithmetic.
Upvotes: 4