Circular linked list – An implementation using C#

In this post, I will explain about creating a circular doubly linked list using C#. .NET framework provides a doubly linked list implementation in System.Collections.Generic.LinkedList class . But this class is not providing the behavior of a circular linked list and it is very tough to extend for supporting circular linked list requirements. In a normal doubly linked list, each node will have a link to its previous and next nodes. Read On →

What Great .NET Developers Ought To Know (More .NET Interview Questions and Answers) – Part1

In this series of posts, I will try to answer the questions posted by Scott Hanselman here. This part we will be seeing the first set of questions he has given under Everyone who writes code heading. Q) Describe the difference between a Thread and a Process? A Thread is a small unit of code in execution. A process is an instance of program which will have multiple threads running. A process can host multiple threads. Read On →

ADO.NET best practices – Reading data from data reader

I have seen many people using DataReader incorrectly. In this post, I will try to explain some good practices that can be followed when reading from a data reader. Consider the following problematic code, SqlDataReader reader = /* ... */; while (reader.Read()) { string userName = reader["user_name"].ToString(); int age = int.Parse( reader["age"].ToString() ); /* ... */ } reader.Close(); How many problems can you figure out from the above code? There are many problems with this code, The columns “user_name” and “age” may or may not exist. Read On →