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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.