Skip to content

Category Archives: C#

Things I learned when re-learning ASP.NET

ASP.NET has changed dramatically in the past five years. I’ve had the privilege to work on some projects using the newer web stacks, as well as modernize an old project. I’d been away from the Microsoft ecosystem from around 2006 until 2011, and after working in dynamic languages (javascript, python, lisp), it took me some […]

installing wiringPi on openelec

I’ve been having fun with Raspberry Pis recently. I’ve got one setup with openelec that I bring on camping trips, with some movies on a USB hard drive. By default, the pi doesn’t provide enough power on it’s USB ports, so I had to use an external USB hub. This meant two AC adapters, and […]

Deploying .NET COM objects with MSBuild

At work I’ve been working with a very old classic ASP website, running on a very old hardware. After a few weeks of hacking vbscript, I’m sorely missing C#, and especially unit tests. I feel so exposed when there’s no tests proving my code does what I think it does. For reasons I’ll not go […]

What learning lisp taught me about other languages

For the last few years I’ve been learning and using Lisp more, and here is a disorganized, poorly-worded dump of how Lisp changed my opinion about other languages. Static Types (as implemented by C# and Java) are oppressive. I spend most of my time in C#, and it always feels like I’m toiling in the […]

brief list of things that make working in C# frustrating

Problem: .NET framework classes don’t use interfaces enough Specific example: DataSource / DataBind()are separately defined on Repeater and GridView, (and Control, and many, many others), and my abstract base class doesn’t care which option an implementor chooses, it just wants to bind the data however the base control wants it. Possible Solutions: Define interface IDataBinding, […]

reading passwords from the console in C#

I’m working on a simple command-line app, and have the need to collect a username and password. I don’t want the password to be printed on the screen as they type, but System.Console.ReadLine doesn’t seem to have any option to mask the input before it’s echoed back to the console. There are a couple ways […]

CAS Authentication in C#

For a recent project I wanted to authenticate using Central Authentication Service (CAS), a single-sign on server deployed world-wide. My project is in ASP.NET, so I hunted down CASP, a C# class produced by John Tantalo at Case Western Reserve University. Coincidentally, John was also responsible for Planarity, a flash game which has only stolen […]

EventHandlerList, key equality, and auto-boxing in C#

I was recently implementing some custom events, and found a couple of good (if old) articles describing how to do this efficiently using EventHandlerList: Manage many events easily with EventHandlerList Objects with dense events, but sparse usage can benefit from custom event storage. Those articles go into why it’s nicer to deal with one EventHandlerList […]

C# generics and XML deserializing

I’ve been playing with generics more, trying to ease the slog of C# development. The .NET framework allows you to do damn near everything, but its so freaking verbose. Almost anything I want to do with framework classes ends up taking 4-5 nearly identical lines, so I end up writing a lot of little wrapper […]

Ease Parsing enums in C# using generics

Once constant annoyance I’ve had with C# has been parsing a string into an enum. Original C#: MyEnum e = (MyEnum) Enum.Parse(typeof(MyEnum), “myvalue”); Using generics let you write a function to help: public static T ParseEnum<T>(string name) { return (T)Enum.Parse(typeof(T), name); } So then you can simply* say: MyEnum e = ParseEnum<MyEnum>(“myvalue”); A little nicer, […]