To explain this, imagine you are designing a type Wrapper<T>, which is just a simple wrapper around a type T.
class Wrapper<T>
{
T value;
public Wrapper(T theObject)
{
value = theObject;
}
// Some [...]
To explain this, imagine you are designing a type Wrapper<T>, which is just a simple wrapper around a type T.
class Wrapper<T>
{
T value;
public Wrapper(T theObject)
{
value = theObject;
}
// Some [...]
Say that you’re implementing a linked list, and you want an enumerator:
public IEnumerator<T> GetEnumerator()
{
return new Stream<T,Node>(first,
node => node.next == null ? null : Tuple.Of(node.next, node.datum).AsNullable());
}
This uses the following utility class to implement the enumerator in one line (along with some code for Tuples [...]
Here’s the source code, as disassembled by Reflector:
public static bool Equals(object objA, object objB)
{
return ((objA == objB) || (((objA != null) && (objB != null)) && objA.Equals(objB)));
}
It seems that not even Microsoft knows this! I spotted this code, from ASP.NET’s MVC implementation, on Scott Hanselman’s blog:
return (other != null) &&
[...]