{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
Introduction to C#
Summary
This article is a quick introduction to the C# programming language.
 
Table of Contents

What is C#?

Relationship with .Net Framework

Figure 1. Relationship between C# and .Net Framework.

The Development Tool for C#

Figure 2. Developing a C# program with Visual Studio

Figure 3. The powerful code editor in Visual Studio

What kind of programs can be developed with C#?

Windows

Web

Mobile

Other

What are some of the biggest advantages of C# over older programming languages?

Garbage Collection

For .Net

Huge Library

Modern

 
Take a Quick Test on this topic: Test Your Knowledge: Introduction to C#

What is C#?

C# is the newest general purpose programming language from Microsoft. It stands on the shoulders of earlier programming language giants like C, C++, and Java. While C# came after Java, it is also considered a language ‘competing’ with Java for the hearts and minds of the developers.

First version of C# was released in mid-2000, while Java was developed and rose to prominence in early 90s. Significant features have been added to both these programming languages since their first releases.

While Microsoft originated C# and is its chief implementer, the language itself is standardized with standards organizations ECMA (European Computer Manufacturers Association) and ISO (International Standards Organization). The latest official C# language specification is Standard ECMA-334 C# Language Specification 4th Edition (June 2006). This document is available for free at ECMA web site (http://www.ecma-international.org/publications/standards/Ecma-334.htm).

Relationship with .Net Framework

While C# is a full-fledged, general-purpose programming language, it must be considered in conjunction with the .Net Framework (.Net platform, .Net environment, or simply .Net).


Figure 1. Relationship between C# and .Net Framework.

DotNet Framework CSharp


As shown in Figure 1, the .Net Framework consists of two major parts – a runtime environment called Common Language Runtime (CLR) and a class library called Framework Class Library (FCL). The runtime environment is a virtual machine (an idea similar to the Java Virtual Machine).

Here, the C# compiler takes the C# code you developed and converts into a language understood by the CLR. The language understood by the CLR is called Microsoft Intermediate Language (MSIL). In developing your C# programs, you would rely upon the vast functionality available with FCL.

The Development Tool for C#

The programs written in C# contain just a bunch of text (series of characters). So, strictly speaking, you would be able to develop C# programs using any text editor, including Notepad. However, developing any decent sized programs with a generic editor would be very painful.

The most powerful Integrated Development Environment (IDE) for developing C# programs is Visual Studio. A program that combines a powerful code editor, a built-in debugger, and GUI based features that ease the program development are called IDEs.

Figure 2. Developing a C# program with Visual Studio

CSharp in Visual Studio

Figure 2 shows the main window of Visual Studio with a Windows Forms program under development. Just to name a few features of Visual Studio:

  • You can visually organize code files into projects and solutions
  • As shown in Figure 2, you can draw the user interface using the tools in the toolbox and the necessary code is generated by the Visual Studio
  • Figure 3 shows a powerful Code Editor. This editor features syntax highlighting (keywords are shown in one color, comments in another, etc.), Intellisense (as you type in code, the editor provides you help intelligently), XML Comments (The comments that start with ///; they can be used to generate documentation)
  • The Community menu lets you post questions and search for the topics of interest
  • The Servers tab provides a way to connect to the databases and do some database development
  • Menus and toolbars visually provide a vast set of functionality to aid development, debugging, testing, building, and profiling

Figure 3. The powerful code editor in Visual Studio

Powerful code editor

Visual Studio comes in several flavors. The high-end Visual Studio Team System costs several thousand dollars; and the low-end Visual Studio Express is free. Even with the Visual Studio Express, you can do amazing amount of development. You can get more information about these products here: http://msdn2.microsoft.com/en-us/express/default.aspx

What kind of programs can be developed with C#?

Just like Java (and other recent programming languages), C# is highly buzzword-enabled. Let’s look at some important uses of C#. Using C#, you can develop programs for Windows, Web, and mobile devices.

Windows

The .Net Framework based windows development is branded as Windows Forms. These are the programs that run on Windows XP and Windows Vista. The client side programs developed this way are called Thick Clients or Smart Clients.

Web

And the .Net Framework features that support the web application development are branded as ASP.NET development. Using this, you can develop user interface and functionality for your web site that works on all the major browsers. The user interface will be developed using a combination of HTML and ASP.NET controls – all of which will be converted to HTML since browsers understand only that. Similarly the functionality developed in C# will either be executed on the server will eventually be converted to HTML/JavaScript for the client side functionality.

Mobile

Using C# and .Net Framework, you can also develop Windows Mobile applications. These programs run on devices like Palm Treo and HP iPAQ.

Other

In all the above cases, you can develop database applications using C#. The database connectivity and interaction is very easy using .Net Framework and C#.

You can also develop applications for Microsoft Office. Finally, you can also develop this sub-category of applications that fall under web, called Web Services. These are web-based programs that don’t have user interface. You call a function from an Internet address with a required set of parameters and that function does the appropriate processing and returns the results in XML format.

What are some of the biggest advantages of C# over older programming languages?

Garbage Collection

Perhaps the biggest advantage of C# over related languages like C and C++ is the automatic memory management, also known as garbage collection. In C/C++, it is the programmer’s responsibility to deallocate the memory once the objects that are consuming it are no longer in use. In C# (and Java), the run-time automatically senses when an object has gone out of scope and returns that memory to the operating system.

For .Net

C# is a clean, simple, and powerful language for doing .Net based development. You can develop .Net programs using C++ (a flavor called C++/CLI), but it is rather painful and unwieldy. You can also develop .Net programs with VB (a flavor called VB.Net), but it feels different from how you think a Basic program should feel like. Needless to say both C++ and VB (or C++/CLI and VB.Net) are there because they satisfy certain need and demand.

Huge Library

The default library for C# is the .Net Framework (or Framework Class Library), which comes with powerful classes for windows and web development. So, you can start developing powerful applications in C# with minimal effort.

Modern

C# comes with the modern object-oriented language features. They include generics, partial and static classes, iterators, anonymous methods, nullable types, and complete integration of database querying right into the language (called LINQ – Language Integrated Query).

Take a Quick Test on this topic: Test Your Knowledge: Introduction to C#
Take a Quick Quiz on this Article

1. Which of the following languages is the closest ancestor of C#?



: It is the other popular language.
Question 1 of 5
Bookmark and Share This

More Articles With Similar Tags
This test has questions on developing basic web services with C# programming language.
This test has questions on the introductory concepts of C# programming language.
This test has questions on the basics of developing an ASP.NET server control program with C# programming language.
Test your knowledge on the basics involved in creating the first ASP.NET Server Control program using C#.
How would you start with developing a Windows Mobile program using C# programming language?
About  Contact  Privacy Policy  Site Map