Faster pixel manipulation with GetPixel and SetPixel in .NET
If you have been playing around much with VB.NET or C#, chances are you have had a go at manipulating images using the System.Drawing.Bitmap namespace. The Bitmap class is great and gives us a nice easy set of functions for finding out the colour of a pixel at a given coordinate, and changing it if we want. But if you are reading this now you’ve probably found out – like I did - that this is really really slow! The reasons for this being so slow are deeply rooted in the .NET runtime (in par...
Read more
Comments(8)
22.08.2006
Using the Visual Basic Input Box in C#
In all versions of Visual Basic as far back as I can remember, there has been the venerable InputBox function which has been great for quickly getting an input from the user. VB.NET has it too, but C# doesn't, and it is sorely missed. [include]adsense_horiz.php[/include] However, there is a simple solution. We can simply "borrow" the InputBox from VB.NET, by adding a reference to the required assemblies. To do this in Visual Studio, follow the steps below In the...
Read more
Comments(4)
22.07.2006
Loading URLs and Files with their default application in C#
From time to time you need to open a URL or file or something else from within your application, for example I've recently been working on a generic "About Box" for my freeware software that has a link to this site in it, the idea being that they click on the link and they get their default browser come up and navigate to it for them. But how do we do that? Actually its absurdly simply - this is the sort of functionality that really sets .Net apart in my opinion. In the old days you had...
Read more
17.06.2006
C# Data Types
Below is a table showing the minium and maximum values (i.e. the range) of the most common data types in C#. These values are based on those found in the MSDN docs. In MSDN some of these values are kinda spread out in various different pages so I've put them together into a single table for easy comparison as I've found the MSDN site pretty slow to browse sometimes. [include]adsense_horiz.php[/include] .NET Type Integra...
Read more
Comments(0)
29.05.2006
C# Enumeration Cheat Sheet
Emumeration in C# is a great technique to use whilst coding - e.g. when dealing with flags in a database you may have lots of different numeric flags, such as "1" for "accepted", "2" for "declined" and so on. Using enumerators you can just use somthing like "Status.Declined" instead of trying to remember what the numbers mean. It certainly beats using static final int all the time! [include]adsense_horiz.php[/include] Overriding Default Values and Underlying Types By default, all enumerat...
Read more
Comments(11)
29.05.2006
Custom .NET Exceptions
The .NET Framework offers programmers a familiar try...catch construct for coping with errors, or exceptions, that arrise duiring run time. The .NET Framework offers a selection of standard Exception classes that deal with some generic situations, such as the ArithmeticException and NullReferenceException classes. These are useful on their own, but when you are developing large, low-coupled systems sometimes you need more. [include]adsense_horiz.php[/include] Fortunately the .NET Framew...
Read more
Comments(1)
23.02.2006
Developing ASP.NET with SharpDevelop
For some time I didn't have a copy of Visual Studio, which made developing ASP.NET code something of a pain - essentially you ended up limiting your self to using .aspx files with inline code and using Trace.Write() or worst still simply echoing out debug messages to the page you were developing - there is only so far you can go like this! [include]adsense_horiz.php[/include] This is where SharpDevelop comes in. SharpDevelop is a free, open source C#/VB.net IDE for use with .NET 1....
Read more
Comments(0)
23.02.2006
Debugging ASP.NET without Visual Studio using DbgCLR
Visual Studio is great, but not everyone can afford it, especially hobbyists althought this is likely to change soon with the new Express versions of Visual Studio 2005. Anyway, at the moment its expensive! There is nothing to stop you creating ASP.NET pages just using something like notepad, but when it comes to debugging your code it can be a real pain - there is only so far that using the Trace.Write() and Response.Write() methods can take you! [include]adsense_horiz.php[/include] However...
Read more
Comments(2)
23.02.2006
System Colours in .NET
Ever wondered what all those AliceBlue or LemonChiffon colours (or color if you are American and googling *HINT HINT*) actually look like? Wondered what their Hexadecimal code is so you can decide which colours to use in your website? [include]adsense_horiz.php[/include] Well you might not have but I have, and because I am often trying to remember what each colour is, here is a handy little reference of all of the System colours that are lurk...
Read more
Comments(0)
23.02.2006
Graphs and Charts in ASP.NET
I've come across a lot of people/companies/sites etc offering graphing and charting products for ASP.NET - all of them have been over $100, some were even approaching $1000 which is obviously a total piss take if you just want a really simple little graph or chart for something! Also, these expensive products may not even give you exactly what you want! [include]adsense_horiz.php[/include] What I'm going to talk about here is using the .NET Framework (and in particular the System.Dr...
Read more
Comments(3)
23.02.2006