Hi, I'm Ray

I'm a software developer, full-time nerd and occasional human (while heavily caffeinated).

Articles + Posts (Tag: C#)

  • 27 May, 2019
  • C#: Building a TNoteBook component for Windows Forms as an user control (PanelBook)
  • Last week I was developing a Windows Forms (WinForms) application that required a particular kind of user interface. The application was a step-by-step wizard that had navigation buttons: "back" and "next". Think multiple steps of a setup installer. Each page occupied the same position and contains other controls. I wanted a more elegant solution other than hiding/showing and moving panels around the form.
  • 25 May, 2019
  • C#: A practical example of polymorphism for everyday projects
  • Every programming textbook and wiki is going to have a definition for polymorphism, so you don't need me to explain the concept. In my mind, polymorphism is the OOP technique of defining one interface that allows different entities to do the work. In this post I'm going to provide a practical example of subtype polymorphism or subtyping.
  • 04 Apr, 2019
  • C#: Storing settings in a SQLite database for a Windows Forms application
  • I find it's a pretty common requirement to store settings for an application, such as: "recently opened files", "last opened path" or other user preferences. I've seen this done using INI configuration files, XML and JSON text files. A few years ago I heard about SQLite; how the likes of Google Chrome were using it for storing configurations. So, I built my own helper to handle reading and writing of settings.
  • 16 Mar, 2019
  • C#: Quick and easy multi-threading on Windows Forms App with BackgroundWorker
  • Today let's talk about a common problem, you have code running and the application becomes unresponsive. If you're running something that's outputting to a textbox or using a control, the application takes considerably more time to run and locks up the form. How are you supposed to use the progress bar if the form just turns grey all the time?
  • 23 Feb, 2019
  • C#: Serialise object to XML (three flavours)
  • I feel like at some point in every project you find yourself needing to serialise an object. My immediate go-to is JSON: whether it's being send to another system or saved to disk, the magicians at Newtonsoft have made it super-easy with JSON. However, when I had a requirement to use XML, the results looked somewhat messier than I expected. Here's what I discovered when serialising an object to XML, in three flavours.
  • 04 Mar, 2018
  • Using Episerver CMS as a makeshift API – Part 2, Stopping at the beginning
  • In part 1, I briefly explained how I came to work on writing an API for an Episerver CMS by exploiting the front-end framework on the web interface. As a developer, with a finite life-span, I jumped straight to the part that I needed for the job. I had intended to go back to the beginning and map all the functionality. Unfortunately I haven't had very much time to spend on this. Together with an amount of uncertainty of my future with Episerver, I'm shelving this. My day job is with Episerver and it's always possible that this API will get reignited by some requirements later. I hope this has been helpful to someone.
  • 01 Jan, 2018
  • C#: Using HttpWebRequest to interact with websites
  • In this article I'm going to show the usage of the HttpWebRequest and HttpWebResponse classes and how you can use it to interact with websites. I'm going to be focusing on retrieving text responses (or the source code of a web pages) and not binary files. I'm also not going to be mentioning WebClient or HttpClient, they may be an article for another time. At the end of the article I'm sharing a helper class.
  • 27 Apr, 2016
  • Parsing CSV in C#
  • Welcome to my first blog post. Hi, I'm Ray (psst! that's the name of this website). This is an easy exercise that I occasionally come across, parsing comma separated values (CSV). I've seen a lot of code purporting to do this on the Web but a lot of it doesn't work in practice. This is my take on parsing CSV's.

Copyright © 2014-2019 Ray Lam. All Rights Reserved.