My .NET and C# samples

Recently, I uploaded on GitHub a lot of .NET and C# samples I have created over the years, as part of my presentations and trainings. You can find them here and download them. All the samples are comprised of  few lines of code that do a specific thing, relevant to the sample’s name. Some of the samples are pretty old and have been superceded by new language/framework advancements (e.g. Linq To XML vs XmlReader) but I’ve decided to keep them in case they prove useful to someone. Small description follows for each sample below:

  • C# Arguments – demonstrates usage of arguments in C# methods
  • Chat with TCP – a chat server and client using the TCP protocol
  • Collections – usage of .NET collections
  • Complex – usage of operator overloading
  • Default Arguments – demo of Parallel.ForEach
  • Delegates – usage of delegates in C#
  • DirectorySearcher – search directories using the DirectoryInfo class
  • DownloadString – WebClient demo
  • Events – simple Button.Click event handling
  • Exceptions – demo of Thread.Abort
  • Extension Methods – C# extension methods
  • Fibonacci – recursively calculating the Fibonacci sequence in C# using Func delegate
  • FileReaderWriter  – FileStream, StreamReader and StreamWriter demo on how to read and write to a file using C#
  • FileSystemWatcher – get notified of file system events (file created, deleted etc.)
  • Generics and IO – demo of a generic Dictionary being written and read from a file
  • Globalization – using globalization classes to display currencies and date/time information in a variety of countries
  • HttpWebRequest – HttpWebRequest demo to connect to an HTTP server
  • MD5 Hashing  – MD5 hashing using C#
  • MultiplyMatrices – multiply two matrices
  • Object Serialization – serialize an object using XmlSerializer class
  • Processes enumeration – get processes that are currently running on your machine
  • Reflection – use reflection in C# to discover information about unknown types and classes
  • Regex and pattern matching – use of regular expressions in C#
  • SendMail – how to send e-mail using C#
  • StopWatch – using a stopwatch in C# to count passing time
  • StringBuilder – an efficient class for heavy string manipulation
  • Threading – how to use threads in C# using classes in the System.Threading namespace
  • Timers – how to use timers in C#
  • XML DOM – read XML via XmlTextReader class

On the folder Other, there are more samples in the various folders. Specifically,

  • Various Windows Phone Samples. Includes

– RevalPaint. A proof of concept Windows Phone XAML application that allows to uncover/reveal parts of an image. Uses XAML Clipping and EllipseGeometry WPPathPainting. Windows Phone XAML app, enables user to paint specific items on a Path via ColorPicker

– MissileLauncherWP7. Controlling a USB missile launcher via Windows Phone (with the help of a Windows application). Check the blog post here and a video here

– XNASamples.

– Includes Simple Puzzle Game –>

– Frogger Game ->

– Bubble Breaker Clone ->

– Arkanoid ->

– WebPageParser. A small piece of code sample to parse an HTML page in Windows Phone 7

– RSSReader. Source code for an RSS in Windows Phone 7. Check the blog post here and the YouTube tutorial here

  • Some Windows 8 User Experience (UX) patterns I’ve worked on. They were presented at EuroPLoP 2013, the premier European conference on patterns and pattern languages. You can check the paper here. I do not maintain the specific solution, check my Universal Helpers project for XAML behaviors and helpful UI stuff for Universal Windows Platform here:
  • CSAsyncWin8: A small demo of the new async keyword in C#. Demo was presented at the first ever Windows 8 development event in Greece, in 2012. Try playing with it by commenting/uncommenting designated lines of code at btn_Start method in BlankPage.xaml.cs to see the results!
  • KinectFirstWords: A proof of concept letter matching WPF application with XAML using Kinect v1 as input
  • WCFSamples: Windows Communication Foundation samples. Includes a Duplex sample (chat client/server), a console app with C# configuration and a Windows Forms app with XML configuration
  • CSharpReflectionSamples: Some C# Reflection Samples.
  • CSharpLanguageEnhancements: Some demos of the C# 3.0 Language enhancements (LINQ, Extension Methods, Object Initializers, auto implemented properties and more). LINQ To SQL demos reguire the Northwind database (

Happy coding!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s