CSTrüter HomeArticlesDownloadsAbout meContact me
a quick look at how to create a windows service using C# 2010-02-28 21:48:06
How to call server-side code from client-side code, using PageMethods in ASP.net 2010-02-21 12:31:27
How to pass a set of data to an xml type in SQL 2005/8 2010-02-12 19:04:23
Some funky behaviour regarding overload Resolution of dynamic/object types 2010-02-09 17:16:52
Object orientated programming within JavaScript 2010-01-28 07:25:45
How to sort data using ASP.net (C#) and SQL 2005/8 2010-01-18 15:23:14
Quick look at some of the new features added to C# 4.0 2010-01-12 21:52:13
SQL 2008 introduced a nifty feature called Table-Valued Parameters (TVP) into its codebase 2010-01-06 22:58:25
How to page data using ASP.net (C#) and SQL 2005/8 2009-10-19 15:01:45
a post about sql joins 2009-09-20 15:50:57
Creating a WYSIWYG textbox for your website is actually quite simple. 2007-02-01 12:00:00
Move items between two listboxes in ASP.net(C#, VB.NET) and PHP 2008-06-12 17:07:43
Firefox word wrapping issues 2008-06-09 09:51:21
2007-02-22 12:00:00
Blog about passing parameters by reference to functions using func_get_arg(s) 2008-07-27 12:38:24
C# 3.0 introduced interesting new functionality, one of them being extension methods, which enables developers to add methods to existing types, without needing to create a new derived type (interfaces, classes, structs) Extension methods behave much like instance methods, but have a number of limitations they can't for example access private nor protected members of the type they're extending. (I can imagine the logic behind this) Note the following code example and how its being defined, you need a static class (all members must be static) and the first parameter of the extension method contains the "this" keyword, informing the compiler which type we're extending. (you may add numerous parameters you wish to pass to this method, but the first parameter must always define the type you want to extend) public static class ExtensionMethods { public static string Reverse(this string value) { char[] charArray = value.ToCharArray(); Array.Reverse(charArray); return new string(charArray); } } Typically (if you did everything right), your extension method should immediately reflect in your IDE (if you're using one), with a little blue arrow. One can also write overloads to existing methods using extension methods, but cant override existing ones - remember that whenever you're planning to use these methods, the static class containing your extensions, obviously need to be brought in scope with whatever code you're planning to use it with (namespaces etc) My feelings on this feature, is that its a tool that must only be used if its REALLY needed. (You can open a tin of tuna with a hammer, but there is better ways to do it) Also if you have access to the source code to a class you need to extend, consider simply adding the method to the class, dont extend it - unless you've got very good reasons. Imagine the impact of misusing this feature (which is true for most others), having your business logic for example, all over the show extended by extension methods, where you potentially come to the point where functionality gets decentralized, it can most definitely lead to some ugly unmanageable code. I've noticed an interesting way Microsoft use extension methods in context with Linq - as soon as you include System.Linq (among others) as a namespace, a number of extension methods gets added, which enables developers to query those types with linq.
public static class ExtensionMethods { public static string Reverse(this string value) { char[] charArray = value.ToCharArray(); Array.Reverse(charArray); return new string(charArray); } }
Codebooth my semi-community site etc (work in progress)
The company I'am currently working for as software developer.
a Parallel reference of programming languages 2009-09-10 12:48:23
a tutorial explaining how to develop a simple login using PHP and MySQL 2009-09-05 18:26:47
An article looking at adding some kind of event driven model to PHP 5 2008-07-28 12:48:09
It is very simple creating your own rss reader, the following article looks at a few methods of doing this. 2008-06-23 13:18:25
A quick reference about working with dropdown boxes (select element) in javascript. 2007-02-17 16:36:41
Collection of funny programming articles 2006-10-08 14:23:43