|
|
On 8/14/2012 7:42, Invisible wrote:
> - "As of C# 2.0, it is also possible to have an array in a structure." (Erm,
> why the HELL would it not be possible to do that before??)
Because structs are fixed size determined by the compiler (and stored in the
stack generally speaking), and arrays are variable sized and stored in the
heap. You can share references to arrays but not to structs, so what happens
when you pass a reference to the array inside a struct and then discard the
variable holding the struct?
> - "x & y" performs a Boolean-OR if the arguments are Bools, and a bitwise-OR
> if they are integers. The same goes for all the other logical operators.
> Except NOT, which has "!x" for Bools and "~x" for integers. WTF?
Makes sense if you think about where those symbols came from, namely C.
> - "x + y" performs addition. Unless either argument is a string, in which
> case the other is converted to a string as well (if not a string already)
> and the strings are concatenated. Unless both arguments are delegates, in
> which case they are concatenated. (I guess there's a /reason/ the Java guys
> claim that operator overloading is evil!)
If you don't know what types you're adding together, you're already in trouble.
> - Goto? Seriously? Well, I suppose /technically/ that's not actually a WTF...
Useful for generated code like state machines.
> - Anonymous delegates /and/ lambda functions?
Yes?
> - A delegate is a thing which is called when an event is fired, but an event
> /is/ a delegate?? (In fairness, this is probably a Wikibooks WTF rather than
> anything to do with the design of C#.)
A delegate is basically a function pointer you can invoke. An event is
basically a delegate with only certain operators (+= and -=) exposed outside
the class that declares the delegate. So think of "event" like "restricted
interface to a delegate".
"firing an event" is exactly the same thing as "invoking a delegate."
> - Extension methods. Just... what??
Useful for LINQ. Useful in general for readability.
> - A non-generic queue is called Queue, and a generic queue is called
> Queue<T>. And yet, for the other container types, the generic and
> non-generic versions have completely different, unrelated names. (I guess
> that's backwards compatibility for you... oh, wait.)
Yep. Generics didn't show up until V3 or so, I think.
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
|