Feeds:
Posts
Comments

Posts Tagged ‘Code’

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 [...]

Read Full Post »

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 [...]

Read Full Post »

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 [...]

Read Full Post »

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 [...]

Read Full Post »

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 [...]

Read Full Post »

FOR XML and ADO.NET

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’)”, [...]

Read Full Post »

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 { [...]

Read Full Post »

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 [...]

Read Full Post »

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 [...]

Read Full Post »

Oops

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 [...]

Read Full Post »

« Newer Posts - Older Posts »

Follow

Get every new post delivered to your Inbox.