The podcast ".NET Rocks!" has a segment called "Better Know A Framework" at the start of every show. The point of the short segment is to simply raise awareness of perhaps lesser known areas of the .net framework. I've found that it's a great way to learn about some things that I simply haven't looked at before.
When Aaron Lerch asked for session proposals for the IndyCodeCamp that he and some others were organizing, I thought it'd be fun to have a "Better Know a Framework" session that had much of the same feel as the segment on the show.
In order to prepare for the talk, I went back through every segment and made a few notes on what parts of the framework was covered as well as documentation links for more information. In case that work might helpful to anyone else, I'm including it as an "appendix" to this post.
The actual talk went pretty well. There were around 30 people at the session (my session was concurrent with 3 other sessions). One of the highlights was the introduction where the hosts of .NET Rocks introduced me (via a recording). Another highlight was being able to throw out flip-flops with my company's logo on them to people in the audience that were first to answer some of the questions I asked.
I created it to show how to use some lesser known classes and namespaces. I also briefly mentioned the "Turkey Test" and its implications on code.
Feel free to download the solution and run through it. If you couldn't make it to the talk, feel free to ask questions via the comments. If you were able to attend the event in person, please fill out the evaluation form online or leave comments here as well.
Thanks to Aaron Lerch and many others who helped organize Indianapolis's first code camp! It was a privilege to get the chance to speak there.
Here's a very brief recap of every "Better Know a Framework" segment since it started. If you'd like more information about it, I included a link to the show where you can listen to it. I also linked to the MSDN documentation for what was covered. I put an asterisk (*) by the show number if I covered that topic in my demo source file.
- 243* - System.BitConverter: Coverts value types like an int to bytes and back. Also determines endianness of the machine.
- 244* - System.Security.Cryptography.RandomNumberGenerator: Much better than System.Random at generating cryptographically strong random numbers.
- 245 - System.Net.NetworkInformation.Ping: which returns a System.Net.NetworkInformation.PingReply that has a System.Net.NetworkInformation.IPStatus which is useful in determining if a remote machine is available (assuming they respond to ping that is).
- 246 - System.Diagnostics.FileVersionInfo: Useful for getting detailed information EXEs and DLLs (such as the company that produced the file).
- 247* - System.Diagnostics.Process: Information about a process on the system such as how much memory it's using, its process ID, main window name, etc. Also includes methods to do things like kill the process.
- 248 - System.Net.Dns Useful for determining the IP address(es) for a given host name.
- 249* - System.Text.StringBuilder: Much faster at building a string than concatenating a string. Discussed in depth on show #87
- 250* - System.Threading namespace: Classes useful in synchronization of threads:
- CPU: Interlocked - Operations performed atomically by the processor (e.g.
- CLR: Monitor and ReaderWriterLock
- 251* - System.IO.FileSystemWatcher: Useful for getting notifications when something on the file system changes.
- 252* - System.IO.Compression namespace: Classes involved in compressing and decompressing files/streams.
- 253* - System.Collections.Stack for LIFO (last-in-first-out) and
System.Collections.Queue for FIFO (first-in-first-out). Also available are generic
and Queue .
- 254 - System.ComponentModel.BooleanConverter: Type converter to and from booleans.
- 255 - Calendars in System.Globalization: Many utilities for manipulating dates in various calendar schemes:
- GregorianCalendar - (most popular)
- 256 - System.Web.Mail: Old (deprecated) way of sending an email.
- 257 - System.Net.Mail: .net 2.0+ way of sending emails
- 258* - System.ComponentModel.BackgroundWorker: Simplifies use of background worker threads that need to update a UI via use of the RunWorkAsync method and DoWork event.
- 259 - System.ComponentModel.BrowseableAttribute
: Can be used to disable a property's visibility in the properties window (e.g. windows forms control).
- 260* - System.Collections.Generic.Dictionary
: Maps keys to values
- 261 - System.Windows.Input namespace: WPF classes used for input (e.g.
InputManager, KeyboardNavigation, Mouse)
- 262 - System.Reflection.Assembly: Useful for finding information about .net assemblies such as classes, interfaces, methods, properties, events, etc.
- 263* - System.Threading.Timer: Simple and lightweight timer. See comparison of timers.
- 264 - System.SerializableAttribute: Marks an object as serializable (able to create a persisted represention of it). A binary formatter/serializer is at
- 265 - System.Xml.XPath.XPathDocument: Provides a fast read-only in-memory representation of an XML document using the XPath data model. See also
System.Xml.XmlReader for read-only XML reading.
- 266 - System.ApplicationException: Intended for use of application specific exceptions, but if you read Best Practices for Handling Exceptions, you'll see that you shouldn't use it anymore.
- 267* - Global Assembly Cache: Otherwise known as the GAC. Provides a system-wide storage facility for assemblies. To put an assembly in the GAC, you need to use the
strong name tool (SN) to get it ready, and then use
GACUTIL on it.
- 268* - System.Console: Besides the obvious methods like WriteLine, there are many lesser-known ones:
- Title (sets what to display in the title bar)
- In (Stdin)
- Error (Stderr)
- Out (Stdout)
- 269* - System.Environment: Contains many assorted details about your application's environment:
- UserName: User name of the person currently logged in.
- WorkingSet: Physical memory mapped to the process
- GetFolderPath: Useful for finding file paths to things like the Program Files folder (which can be different depending on if you're running 64 bit Windows)
- 270 - System.Net.HttpWebRequest , HttpWebResponse , WebRequest classes: Lower level classes used to perform an HTTP request. See notes on show #275 for the much simpler WebClient class.
- 271* - System.IO.StreamWriter and StreamReader: Helper classes for dealing with text files/streams (contains methods like ReadToEnd() for returning a string of whatever is left in the stream)
- 272 - System.Windows.Forms.Splitter: Control that allows you to split parts of a UI in a way that allows the user to expand or shrink an area. This class can be hard to use, see show #273.
- 273 - System.Windows.Forms.SplitContainer: Much simpler way to provide a split UI.
- 274 - System.Windows.Forms.ToolTip: An
extender provider that allows you to add Tooltips to all items in a container's scope. It implements System.ComponentModel.IExtenderProvider. Similiar to how
- 275* - System.Net.WebClient: Provides a very easy way to perform common HTTP operations in 1 line of code (e.g. DownloadFile, DownloadData)
- 276 - System.Web.UI.Page: SavePageStateToPersistenceMedium and
LoadPageStateFromPersistenceMedium allows you to store viewstate in a different place besides sending it down to the browser each time. This can be useful as viewstate can account for a large (67%+) part of your page's size.
- 277 - System.Web.Management namespace: Classes that do all sorts of management of web servers and web farms. For example, WebAuditEvent allows you to audit web events.
- 278 - System.IO.IsolatedStorage: (In this show Carl thought that IsolatedStorage was used for storing things in a secret way. See show #278 )
- 279* - Christopher Loaf from Sweden pointed out that System.IO.IsolatedStorage is primarily used for storing and retrieving data in a partial trust environment (e.g. a web browser).
- 280* - System.Convert: Methods for converting items from one type to another (e.g
ToBoolean, ToChar, ToBase64String, FromBase64String). In addition, has IsDBNull to determine if an object is a database null value.
- 281* System.Globalization.CultureInfo: Used for ensuring that you retrieve, store, and process information according to a specific culture. For example, if you do DateTime.Now.ToString("D"), you'll get the date formatted in a culturally specific way as outlined by this class.
282 - System.Guid: Class used for handling global unique identifiers.
- 283 - System.IO.Packaging: Provides classes that support storage of multiple data objects in a single container. (Most notable example is Office 2007+ documents, see show #285 )
- 284 - System.Security.Cryptography.SHA1: Hash algorithm that has been
academically broken and therefore shouldn't be used anymore for safety reasons. The framework also has unbroken ones such as SHA512 which uses 512 bits instead of 160 bits, but is much more secure.
- 285 - Comments about the Guid class and how System.IO.Packaging is really useful for reading Office 2007 documents such as Word files)
- 286 - Microsoft.Windows.Themes: Classes used by WPF to provide visual appearance that is similiar to Vista, XP, and Window 2000 and lower (Luna, Aero, Royale, and Classic).
- 287* - System.IDisposable: Useful for controlling exactly when resources get released. An early Dotnetrocks show with Chris Sells talks about it in depth.
- 288 - No Better Know a Framework segment.
- 289 - System.ICloneable: Originally designed to provide a way of determining how to create a clone (copy) of an object. However, Brad Abrams recommends not to implement it in public APIs since its semantics are confusing.
- 290 - System.Security.Principal.WindowsPrincipal: Contains methods for determining information about the current user's Windows account information (e.g. use
IsInRole to determine if the user is an administrator)
- 291* - System.GC: Methods and properties pertaining to the built-in Garbage collector (see show #287 notes as to how this relates to System.IDisposable)
- 292 - System.CodeDom and System.CodeDom.Compiler namespaces: Classes for manipulating source code and their compiled forms.
- 293* - System.Math: Class containing many common math operations
- Absolute Value
- BigMul: returns full product of two 32 bit numbers (64 bit result)
- 294* - System.TimeSpan: Many methods and properties that are useful in working with a span of time (e.g. 30 minutes)
- 295* - System.WeakReference: Class that holds onto an object reference but gives clues to the garbage collector that the reference can be let go of if memory pressure arises.
- 296 - System.DataMisalignedException: Obscure exception that can be thrown if data is read from or written to memory that isn't aligned according to what the processor expected.
- 297* - System.Text.RegularExpressions.Match: Regular expressions are very useful for parsing and manipulating text. See this reference for a sampling of what types of patterns you can use.
- 298 - System.Resources.IResourceReader interface: You can use a ResourceReader or
ResourceWriter for using resources that can be stored elsewhere besides inside the assembly.
- 299 - System.Web.HttpResponse.TransmitFile: Provides a simple way to write a file to a stream.
- 300 - No Better Know a Framework segment
- 301* - System.Collections.IEnumerator and System.Collections.Generic.IEnumerator
: Interfaces used for specifying how to enumerate (go one by one) through a collection.
- 302 - System.Speech.Synthesis namespace: Classes for creating speech from text
- 303 - Microsoft.VisualBasic.Compatibility.VB6 namespace: Classes for handling compatibility with VB6 semantics in .net.
- 304 - System.Drawing.Printing.PrintDocument: Class that has methods and events (e.g.
PrintPage) for easy use with printing.
- 305*- System.IComparable and System.IComparable
: Has a
CompareTo method to determine how two objects relate to each other (Carl focused on equals, but you can also do greater than and less than).
- 306 - System.IO.Ports: Classes like SerialPort which are used for serial communications.
- 307* - Email from Thomas Betz about show #305 on System.IComparable discussing how it's most commonly used for sorting. The System.Object.Equals and System.IEquatable are better suited for determining equality.
- 308 - HTTP Handlers implementing System.Web.IHttpHandler: For example, you can register your code to be called when IIS processes a certain file extension.
- 309* - Discussion of C#'s yield keyword and how it can be used.
- 310* - Discussion of the new type inference feature in C# 3 and VB 9 so that you don't have to bother defining an object's type.
- 311 - System.Web.IHttpModule: Can be used to handle processing in the HTTP life cycle such as authentication, logging, and redirects. See Creating and Registering a Custom HTTP Module for more information.
- 312 - Discussion of the new anonymous types feature in C# 3 and VB 9.
- 313 - System.Collections.ObjectModel.ObservableCollection
: Collection that has events for notification of when the collection has been modified.
- 314 - System.Windows.Converters: Classes like Int32RectValueSerializer which are used by WPF to persist objects to a string.
- 315* - System.IFormattable: Allows you to specify special string formatting options in
String.Format and ToString.
- 316 - System.Nullable
: Generic wrapper for value types that allow for the possibility of a null.
- 317 - System.Net.PeerToPeer namespace: Classes providing access to peer network functionality such as how peers discover each other using the Windows peer to peer infrastructure (e.g. PNRP - peer name resolution protocol)
- 318 - System.Net.PeerToPeer.Collaboration namespace: Enhances the peer-to-peer networking functionality and provides capabilities for serverless, managed collaboration sessions.
- 319* - System.Linq.IQueryable: Used by LINQ to evaluate queries.
IQueryProvider creates and executes these.
- 320 - System.IO.Pipes namespace: Classes for working with interprocess communications using pipes.
- 321* - System.AppDomain: Encapsulates working with an application domain (a lighter weight than an process, but used by the CLR to provide isolation). See show 8 with Rocky Lhotka for a discussion on them.
- 322 - System.AppDomain.AssemblyResolve event: This method is raised if code in an AppDomain tries to find an Assembly and is not able to. See this knowledge base article for how to use it.
- 323 - System.AppDomain.DoCallBack method: Useful for executing a callback in another AppDomain.
- 324 - System.Web.Mobile namespace: Classes for use with mobile web devices.
MobileCapabilities class can be used to determine things like a client's screen size.
- 325 - System.Delegate: Class encapsulating a single method; sort of like a function pointer but better.
- 326 - More on delegates and how they are a combination of a code pointer plus the metadata including an invoke method.
- 327 - System.Configuration.IPersistComponentSettings: Defines standard functionality for controls or libraries that store and retrieve application settings.
- 328 - System.Windows.Xps namespace: Classes like
XpsDocumentWriter for saving XAML objects to a PDF like format.
- 329 - System.Data.IDbDataAdapater: Interface used by
System.Data.Common.DbDataAdapter and others built from it to fill a
- 330 - System.Net.Sockets namespace: Classes for use with low-level socket communication. See DNR TV show (part part 1 and 2)
- 331 - No Better Know a Framework segment.
- 332* - System.String Compare method: Useful for performing a culturally sensitive string comparison. See System.Globalization.CompareOptions.
- 333* - System.Diagnostics.Trace: Class used to trace (record) what paths are executed in your code. If you've ever used Console.WriteLine, you'll find Trace.Write and Trace.WriteLine similar. They write to a listener.
- 334* - System.Diagnostics.TraceListener: Base class used to implement trace listeners (destinations/outputs for Trace.Write). For example TextWriterTraceListener writes to text files. You can use a config file to add/modify the listener without modifying code. In addition, you can do it dynamically in code via the Trace.Listeners.Add method.
- 335* - System.IO.FileInfo: Provides many details about a file:
- 336*: System.IO.MemoryStream: Provides an in-memory version of a
Stream. Much easier to work with than a byte array.