Use C#’s regular expression library to Convert TimeSpan and DateTime to and from strings. (Named capturing groups!)December 20th, 2010
Well that title is a mouthful. Long story short, as an exercise in regular expressions I wrote a utility class to convert strings to TimeSpans and DateTimes in C#. This made great usage of named capturing groups. (The download to the source code is at the bottom of this post.)
Here is the DateTime regular expression. Note that when I new the regular expression object, I set whitespace and casing ignoring.
Named capturing groups allows code like this:
fun! Download all of the code here.
Have any suggestions about the code? Any neat C# features I should have used? Comment below!
After returning home from college for the summer, I wanted to get my desktop computer online with the wireless network. Unfortunately for my Internet addiction, the desktop computer didn’t have a wireless adapter. I ordered one off of NewEgg, but in the mean time I was left without the glorious internet on my desktop computer’s big screens. What do I do?! The laptop could connect to the wireless network, so there’s a start. Windows has the ability to share the Internet connection of one network adapter over another. Bingo. I describe the process in the following video.
My computer screen turned yellow the other day when I moved it. I knew the problem was that the DVI cable was loose, but I could see that some people might think that the screen was broken. (Gosh, I’m so smart!) Anyway, here is this post showing the problem, in the hopes that it will help some poor googler wondering what’s wrong with his screen.
After lots of googling, trying to figure out how to multithread properly in .NET and modify a WPF GUI from another thread, I’ve finally figured a lot of stuff out. I have created a simple multithreading example project in Visual C# 2008 Express.
You can download the project here, but since I know most people just want to get some quick answers, here’s a few code snippets:
If you have a copy of Windows 7 installation media as an ISO (disk image) you may want to put it on a flash drive. You might think that you’d be able to just click and drag the file onto the flash drive and be done, but that isn’t the case! Here’s how to do it
First, have a Windows 7 ISO (duh)
Next, download and install Microsoft’s ISO tool here. (That is a direct link, originally found the link here. If you’re doing this on Windows XP, go to that page and scroll down to “For Windows XP Users” to find two more downloads you will need.)
When you open the program, it will look like this.