Techbubbles

Archive of ‘C#’ category

Singleton Design Pattern in C#

Best known Creational Design Pattern is Singleton. We can implement this pattern in different ways. I am explaining some of the ways where we can implement in C#. We will have the following concepts in implementing the Singleton pattern We declare a private constructor which prevents other classes to create an instantiation of the singleton […]

C# IDE Tips & Tricks Part 1

C# Developers have been spending most their day activities with Visual studio IDE. They may have to understand the following activities to do their job. Understanding Code Developer must be able analyze the relationship between classes and what API it is using for implementing the logic. Navigating Code Developer may or may not know where […]

C# ?? operator

The ?? operator in C# called null-coalescing operator is used to define a default value for a nullable value types and reference types. It returns the left-hand operand if it is not null and returns right-hand operand if it is null. example // ?? operator example . int? x = null; int y = x […]

Using keyword in C#

Introduction Using keyword in C# can be used as directive and as well as statement. When you use using as Directive you will get the following advantages You can use the types in a namespace by declaring with using keyword.         example: using Systetm.Web;   You can define a alias for the nested namespaces        […]

The Future of C#

Introduction This post speaks about the future of C# which presented by Anders Hejlsberg chief architect of C# at PDC 2008. The coming version C#4.0 is much concerned on introducing Functional and Dynamic programming language concepts into the C#. It also speaks about C#4.0 features. The factors that shape the C#4 are Declarative programming Dynamic […]

Lambda Expressions in C# 3.0

Lambda expressions is one of the features introduced in the C# 3.0. Lambda expressions help you to ease the burden of writing verbose Anonymous Methods. I will explain the where to use the Anonymous methods first then we see the example on lambda expressions Anonymous Methods Anonymous Methods is the feature in C# 2.0. The […]

Object and Collection Initializers Feature in C# 3.0

C# 3.0 introduced the another interesting feature Object and Collection initialization expressions. Object Intialization  Expressions allows you to initialize an object without invoking the constructor and setting its properties. If you take Employee Class as an Example: public class Employee { private int iEmpId; private string strFirstName; private string strLastName; public int ID{ get{ return […]

Automatically Implemented Properties Feature in C# 3.0

Introduction of Automatic Properties in C# 3.0 make property declaration more concise. It saves some of your time in typing a lot of code. Example: class Employee { public string FirstName { get; set; } } Benefit of using Automatic Properties We have been creating properties in so many projects and notice that we are […]

Test driven development using C#

This post explains how TDD can be implemented in C# using NUNIT. You can read the Introduction TDD to get an idea on TDD. Nunit is a open source framework to for .NET which helps you to automate the unit testing. Nunit can downloaded from the Nunit site. current version is 2.5. Nunit provides two […]

C# 3.0 features

The following features are introduced in the C# 3.0 Visual studio C# 2008 1. Lambda Expressions. 2. Extension Methods. 3. LINQ Query Expressions. 4. Anonymous Types. 5. Expression Trees. 6. Partial Methods. 7. Auto-Implemented Properties. 8. Object and Collection Intializers.