Archive for the ‘c#’ Category

XElement and friends

System.Linq.Xml - The XML object model for Linq
XElement is the basic building block (or element) of an XML document in the System.Linq.Xml world. It is, after all, just an XML element. Using XElement, the most basic XML document can be formed with this:
PLAIN TEXT

XElement doc = new XElement("DocumentRoot");

This will give you a document that [...]

Those old C bit tricks

After spending a lot of years writing C code it is sometimes hard to get some of those "tricks" out of your mind. The thing I always felt about C was it seemed to encourage you figure out or use cool tricks. Couple that with graphics coding you can get some strange stuff like the [...]

A lambda function as an Event Handler

Did you know you can use a lambda function as an event handler?
For example:

dog.PropertyChanged += (object o, PropertyChangedEventArgs a)
[...]

Basics - Anonymous Types outside the scope of Linq

Some basics.
Anonymous types are an important new feature that allow, at compile time, for the type information for a variable be dropped by the developer. For example:

1: var x = 128;

Line 1 declares the variable x as a variable having an anonymous type using the var keyword. At this point, nothing [...]