Tag Archives: C#

Caching Sequences: Quick and Dirty

In F# we have this wonderful Seq.cache function which allows us to cache the results of a Seq object (also known as IEnumerable). Unfortunately, C# has no such function, and implementing it yourself usually involves implementing an extra class to hold the data.

Continue reading


Designing a Functional Rendering Pipeline

Well, it’s been ages since I last blogged anything. I feel ashamed… It’s been quite busy on my end. I’ve had plenty of projects to work on.

There’s a bright side to all this – I now have two more languages solidly under my belt! The first is C++, which is something I’ve only had really basic knowledge on up until now. I’ve been neglecting it mostly because it sucks, but it’s become a lot easier to stand now that the new version is finalized. Glory be to lambdas on high!

Continue reading

Emulating the Command Prompt in C# (Part 2)

Last post I demonstrated how to make a simple command prompt using a basic Console project. This time I’m going to show how to embed one in a window.

I’ll admit it, getting this to work was not particularly easy. I tried a number of different methods, from redirecting the output stream to parenting the console window. Redirecting the output stream didn’t work because not all of the output could be read until the program finished executing. Parenting the console window didn’t work because it wouldn’t draw correctly when I removed the border. In the end, I had to copy the text from the console buffer itself.

Hooray, more P/Invoke.

Continue reading

Emulating the Command Prompt in C#

The school I go to places ridiculous restrictions on the computers. Right clicks aside, one thing I wish above all things they hadn’t disabled was the command prompt. Ironically, the computers also have support for a number of programming languages. A friend of mine managed to emulate one using Python, and all was swell. The best part was that he coded in functionality to automatically add things to the system path. You see, we were doing quite a bit of C++/MinGW at the time… off our USBs of course.

I decided to make my own. The Python script had the added bonus of being cross platform, but it would be quite the stretch to expect every Windows machine in the world to have Python installed. I wanted my own custom command prompt. Because I rarely use Mac/Linux, .NET is installed on all up-to-date Windows machines, and it’s simply an awesome language, I decided to use C#.

Continue reading