I am confusing about using ==
in (c#)
when I use literal string like here:
object a="hello";
object b="hello";
the comparison a==b
will be true.
but when I use object like here:
object c=new StringBuilder("hello").ToString();
object d=new StringBuilder("hello").ToString();
the comparison a==b
will be false.
even though a,b,c,d
all of type System.Object in compile time and
==
operator compare values depends on their values in compile time.
I use extension method to get type of varabiles during compile time:
public static class MiscExtensions
{
public static Type GetCompileTimeType<T>(this T dummy)
{ return typeof(T); }
}