Welcome to weblogs.com.pk Sign in | Join | Help

Default(T)

If you are using Generics; chances are that you might be using null checking technique for the undefined value scenario. The glitch is; if <T> is value type; then check of null equality will always fail. One should use a newly added keyword; default(T) instead.

Further; If you want to use value types; you should also use null-able value type.

[TestMethod()]
public void
DoubleCircularListTests()
{
   DoublyCircularList<int?> target = new DoublyCircularList<int
?>();
   target.AddAtTail(1); 
   target.AddAtTail(2);
   target.AddAtTail(4);
   target.AddAtHead(3);
   target.RotateClockWise();
   target.RotateClockWise();
   target.TraverseClockWise();
}


Published Friday, April 28, 2006 7:55 PM by khurram
Filed under:

Comments

No Comments

New Comments to this post are disabled