I came across this channel 9 Microsoft Security Wiki that contains some nice code examples for common security programming tasks (in C# and VB.NET), such as generating cryptographically secure random numbers. Not only does it show the correct way to perform a task but also provides ‘how not to’ example code.