Port of the VB.NET sample application to C#