I was reading about Nullable Types in the C# 2.0 specification for the .NET Framework 2.0 today. I am surprised I didn’t find out about this feature long ago, goes to show that you learn something new every day. So what are Nullable Types? Simply put, Nullable Types are value types that a can be [...]
Posts Tagged ‘Code’
Nullable Types in C# 2.0
Posted in Everything, Software Development, tagged C#, Code on August 30, 2005 | 2 Comments »
Event catch-up in ASP.NET 2.0 Controls
Posted in Everything, Software Development, tagged ASP.NET, Code, Web Development on August 19, 2005 | Leave a Comment »
Pop quiz, what is wrong with the following class? public class MyPlaceHolder : PlaceHolder { protected override void OnInit(EventArgs e) { Page.Trace.Write(this.ID, “In OnInit”); base.OnInit(e); } protected override void OnLoad(EventArgs e) { Page.Trace.Write(this.ID, “In OnLoad”); base.OnLoad(e); } protected override void OnUnload(EventArgs e) { Page.Trace.Write(this.ID, “In OnUnload”); base.OnUnload(e); } protected override void OnPreRender(EventArgs e) { DropDownList [...]
Firing multicast delegate events
Posted in Everything, Software Development, tagged C#, Code on August 17, 2005 | Leave a Comment »
I am currently writing an ASP.NET server control, which exposes a number of custom events. I was looking through my code archives for a helper class, which will safely call handler methods of a multicast delegate, when an event is triggered. I found the class I was looking for, and decided to publish it here [...]
HTML to XHTML using SGMLReader
Posted in Everything, Software Development, tagged Code, Web Development on August 9, 2005 | 6 Comments »
Chris Lovett wrote a wonderful .NET library called SGMLReader, which, when passed a regular HTML file will spit out XHTML. The library relies on SGML parsing and uses a DTD (Document Type Definition) file to parse unformatted HTML. I’ve been playing with Chris’s library this week and trying to convert HTML to XHTML on the [...]
IPostBackDataHandler and IPostBackEventHandler
Posted in Everything, Software Development, tagged ASP.NET, Code on August 2, 2005 | 8 Comments »
I’ve been messing around with post back handler in ASP.NET today, and I found out a few points of interest. Firstly, a description of the two interfaces used with server controls to handle post backs: IPostBackEventHandler – Implemented by server controls that wish to handle post back events. The RaisePostBackEvent method is invoked by the [...]
FOR XML and ADO.NET
Posted in Everything, Software Development, tagged Code, SQL on August 1, 2005 | 1 Comment »
My esteemed colleague Sahil Malik has blogged about using FOR XML in SQL server. The following C# example demonstrates how to retrieve XML data from a SQL Server 2K5 database as XML: using (SqlConnection conn = new SqlConnection(“…”)) { using (SqlCommand cmd = new SqlCommand( “select’Rob’ as [Employee/@EmployeeName],’A cool dude’ as [Employee] FOR XML PATH(‘Staff’)”, [...]
How many bad developers are there in the world?
Posted in Everything, Software Development, tagged Code on July 29, 2005 | 6 Comments »
As I was reading today’s “Daily WTF” I could not help but wonder about how many really bad developers are out there in the market place. The following snippet was submitted to D-WTF after being found in some production code: public boolean checkFalse(Boolean bool) { if (bool.booleanValue() == Boolean.FALSE.booleanValue()) { return Boolean.FALSE.booleanValue(); } else { [...]
Code Comments
Posted in Everything, Software Development, tagged C#, Code on July 2, 2005 | Leave a Comment »
I have lost count of the number of times that I have been asked to work on a piece of software written by another developer, only to find out that the code had no comments. What typically follows is hours spent wading through lines and lines of complex instruction to determine how the software was [...]
Question about generics
Posted in Everything, Software Development, tagged C#, Code on May 27, 2005 | Leave a Comment »
In my previous post on Generics, I received a comment from Eddie, who was asking why developers would want to use the following constraint, in the example below, when he would pass the parameters as IComparable interface types. public static bool IsLessThan(T one, T two) where T:IComparable { return one.CompareTo(two) < 0; } public static [...]
Oops
Posted in Everything, Software Development, tagged C#, Code on May 26, 2005 | Leave a Comment »
I forgot to mention in my last post, about Generics, that Sahil Malik helped me out with the solution. Between the two of us we figured out why parameterized constructors are not allowed when creating new instances of generic types. I would have edited my initial post, but the formatting in my blog that displays [...]
