Re: Why can't switch be used for objects



1. Because it would be grossly slow.
2. Because the semantics of comparison are unclear (do you use equality
by reference, or use the Equals method, or do you allow IComparers,
or... ?)
3. Because if you need this then there is probably some other (cleaner)
way to do what you want to do... which is why I'm wondering exactly
where you need this switch statement and for what, in order to propose
an alternate design. :-)

.



Relevant Pages

  • RE: == versus .Equals()
    ... Everything has an Equals method. ... Classes can override it to provide value equality if they ... struct designer did not overload it, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is FreeBSD a Novelty Operating System?
    ... the windows system cannot be used for much of the new windows ... Sentence is unclear, but perhaps a reference to the upgrade to Xorg 7.2. ...
    (comp.unix.bsd.freebsd.misc)
  • Re: Find Filter Problems
    ... See if it works if you use a range test and not equality. ... Testing any date/time value for equality might always fail due to conversions from UTC to local time and rounding errors. ... As for using in my filter expression, ... this search returns a null reference. ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: Question about "Contains" method
    ... 'Contains' method internally uses Equals method to compare the ... For reference types, equality is defined as ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SoftReference operation synchronization detail
    ... we should clear up some terminology and basic concepts. ... Thank you and thank to Robert and Thomas for your answers. ... In the above sentence of mine "Reference" ... As I've written my confusion came from some unclear tests of mine I've ...
    (comp.lang.java.programmer)