Archive for the ‘C#’ Category

Structs….. A light-weight Class

In C# Structs are a lot like classes. Both expose variables, properties and constructors. Both are used to organize data or a common type that organizes your code. There are some differences between the two. For one, Structs are value types while Classes are reference types. What does this mean? Well value types hold their [...]

How To Implement IDisposable Interface

The IDisposable Interface exposes the Dispose method which must be implemented by any class that inherits this Interface. It should be used to release any un-managed resources of an object that have been initialized, like Database connections, handles, streams and files. You should also call GC.SuppressFinalize. This will keep your object from landing on the [...]

How To Change Target Web Service At Runtime

Introduction
While developing clients for web service, we typically add a web reference to the web service by specifying URL of the .asmx file. Adding a web service in VS.NET generates required proxy object. However, it may happen that after adding the web reference the web service is moved to some other location. [...]

How To Handle Timeouts in Web Services

Introduction
While developing web applications you should also consider factors like network downtime and server crashes. The same applies to developing web services. When you call a method from your client by default it waits infinitely for the response. This means if server hosting the web service is down then you are bound to get error [...]

How to use Asynchronous Program In .NET

Introduction
Support for asynchronous programming is built right into the .NET framework. Asynchronous programming model not only can improve your overall performance but can also make your application more responsive. In this article we will develop a complete example that shows how to develop your components to take advantage of this technique.
About the example
We will develop an [...]

How To Execute External Applications From Your .NET Application

In some cases you need to execute some external appilaction from your own application. The common candidates for such task are:

Running BCP in SQL server
Running batch scripts that automate some tasks
Start some add-in application like text editor
Opening read me kind of files at the end of installation

.NET provides an easy way [...]

Object Oriented Programming with VB.NET and C#

Introduction
.NET is fully object oriented platform that allow languages to take full advantage of these OO features. The features include:

Namespace
Classes
Objects
Encapsulation
Overloading
Inheritance
Overriding
Interfaces
Polymorphism

Let’s take a quick look at what each of this term means.
Namespace
Even though namespace is not really an OOPs feature, .NET use it extensively. Namespace is nothing but a logical container for various classes. Under given [...]

How To Serialize XML using C#

Serialization is a process of storing state of an object to some media like disk file or stream. Few weeks back we saw how to serialize objects to disk file in binary format . .NET further provides a way to serialize objects in XML format . Thus objects can be converted into XML documents (serialization) [...]

Attributes Introduction

As you might be aware that .NET assemblies are self describing i.e. the information about each assembly is stored in the assembly itself. This information is called as Metadata. .NET allows you to put your own information in the metadata. The way to accomplish this is through Attributes. In this article we will see how [...]

.NET Reflection Introduction

Reflection is ability to find information about types contained in an assembly at run time. Prior to .NET languages like C++ provided such ability in a limited sense. .NET provides a whole new set of APIs to introspect assemblies and objects. All the APIs related to reflection are located under System.Reflection namespace. .NET reflection is a [...]