Event Keyword & Comparisons
I didn't attend the PDC, but have been overall quite satisified with the
volume of information about .NET/C#. However, there's a few questions not
immediately obvious from the on-line info:
In the C# Reference manual, they describe an event keyword can be used to
simplify the addOnXXX/removeOnXXX event coding convention. The idea is that
you can write a public delegate field for your class, but thanks to the
event keyword only the operators += and -= can be used on the delegate from
outside of that class. I haven't seen this in any of the C# examples
outside the reference manual though. Do you have to give up this C# feature
when writing event-code so that all languages using .NET can use your
events?
It appears that the object's == method is not virtual. Does this mean that
a general purpose class, say a collection class, cannot make use of the ==
method to compare 2 objects by value, rather than identity? Would the
general purpose class have to rely on the IComparable interface? This leads
onto another issue. If a C# class implements the IComparable interface,
then it would seem natural for C# to implicitly define <, <=, >, >= methods.
I'm hoping that C#'s handling of ==, <, <=, >, >=, (object)a==(object)b, and
ICompareable comparisons are not prone to programmers making mistakes!
I've got more questions - but I'll see if anyone answer these before I ask
them. Thanks for your time!
Ben Albahari,
Genamics.

