Visual C# Tutorials

Overview of C# 3.0 Anonymous Types

10 July 2009
9129 Views

Microsoft introduced some great new features in C# 3.0 to make developers more productive. Most of those features are introduced to support Language Integrated Query (LINQ) but they can also be used in many other scenarios. One such feature is Anonymous Types that allows you to define a class with some simple encapsulated fields without any associated methods, events or functionality. In this tutorial I will give you overview of C# 3.0 Anonymous Types.

Overview of C# 3.0 Object Initializers

30 June 2009
6703 Views

When you create object of any type in C#, it is very common to call its default constructor using new keyword and then set the object properties one by one. The new object initializer syntax introduced in C# 3.0 makes it easier for us to initialize our objects in one statement without calling the object parameterize constructor. In this tutorial I will give you an overview of this new Object Initializer feature of C# 3.0.


Understanding C# 3.0 Extension Methods

29 June 2009
7165 Views

As you know, once a type such as class, interface, and structure is defined and compiled into a .NET assembly, it is not possible to add new members or update existing members without opening and changing the source code and recompiling it again. In C# 3.0, Microsoft introduced a new feature called Extension Methods that enable developers to add new functionality to existing precompiled types. These types can be either .NET Framework built in types such as String and DateTime or they can be your custom types. In this tutorial I will try to give you a complete overview of extension methods.
Understanding C# 3.0 Extension Methods

Overview of C# 3.0 Automatic Properties

18 June 2009
6020 Views

All .NET programming languages prefer the use of Properties to encapsulate the private fields available in the class. There is nothing too problematic with Properties but sometimes when you need properties simply to assign and return the value stored in a private field it looks quite a lot of work especially if you have to declare properties for 15 to 20 private fields. To automate the process of providing simple encapsulation of field data C# now has a new syntax to generate automatic properties. In this tutorial I will show you how you can create Automatic Properties and how you can use them in your programs.

Implicitly Typed Local Variables in C# 3.0

17 June 2009
21035 Views

Microsoft introduced quite a number of new features in C# 3.0 and later version and most of them are added in the language to support another new technology LINQ. One of those features is implicitly typed variables that allow you to create a local variable by using a newly added var keyword without giving it a specific type. In this tutorial I will give you introduction of implicitly typed variables and their use in your programs.

Singleton Design Patten in C#

25 May 2009
5018 Views

The singleton pattern is one of the most known and easiest design patterns in software engineering. In simple words, a singleton is a class which only allows a single instance of itself to be created. There are various different ways to implement this pattern in C#. In this tutorial, I will show you how you can implement the singleton design pattern with minimum amount of code.

Using XmlTextWriter to write XML Documents in .NET

16 May 2008
12605 Views

XML is one of the most popular topics these days. As the use of XML files is increasing, more and more developers want to learn how to write, read and consume XML documents from different programming languages. In the following tutorial, I will show you how you can use .NET Framework built in class XmlTextWriter to generate XML document in C#.
Using XmlTextWriter to write XML Documents in .NET

Using C# Delegates with Events

02 May 2008
11786 Views

.NET Delegates are objects which can refer to static and instance methods in memory at runtime and can call those methods in your program. In this tutorial I will show you how you can create and use delegates in C#.
Using C# Delegates with Events

Storing Database Connection Strings in App.Config

08 April 2008
89319 Views

Storing database connection strings in source code can lead you to some security issues and can also cause you maintenance problems. It is always recommended that you keep your connection strings in a separate configuration file so that you can change database connection related information such as password or database name without even modifying or recompiling your source code.

Application Configuration Settings in .NET

08 April 2008
13463 Views

Saving and restoring application settings outside source code is crucial part of any software application. .NET Framework provides very simple solution for saving application settings in .config files. Framework also provides classes to read these settings in .NET application in a very easy way. In the following tutorial, I will show you how you can store and retrieve application settings stored in App.config file in .NET windows application using C#.