C# - Introduction & Features

Microsoft developed C#, a new programming language based on the C and C++ languages. Microsoft describes C# in this way: ”C# is a simple, modern, object–oriented, and typesafe programming language derived from C and C++. C# (pronounced c sharp) is firmly planted in the C and C++ family tree of languages and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of visual basic and raw power of C++.”

Anders Hejlsberg, the principal architect of C#, is known for his work with Borland on Turbo Pascal and Delphi (based on object–oriented Pascal). After leaving Borland, Hejlsberg worked at Microsoft on Visual J++.

Some aspects of C# will be familiar to those, who have programmed in C, C++, or Java.C# incorporates the Smalltalk concept, which means everything is an object. In other words, all types in C# are objects. C# properties are similar to Visual Basic language properties. The Rapid Application Development (RAD) goal in C# is assisted by C#’s use of concepts and keyword, such as class, structure, statement, operator, and enumeration. The language also utilizes the concepts contained in the Component Object Model (COM) architecture.

Unlike Visual Basic or Delphi, Events is a type in C# and can belong to an object. Members of a class object can have variables, methods, properties, attributes, and events. Attributes are another nice feature of C# language.

NOTE: C# is a case sensitive language. E-Books

C# Language Features

C# was developed as a language that would combine the best features of previously existing Web and Windows programming languages. Many of the features in C# language are preexisted in various languages such as C++, Java, Pascal, and Visual Basic. Here is a list of some of the primary characteristics of C# language.

    1. Modern and Object Oriented

    2. Simple and Flexible

    3. Typesafety

    4. Automatic Memory Management

    5. Versioning Control

    6. Cross Platform Interoperability

    7. Advanced features introduced in C# 2.0 and 3.0

1. Modern and Object Oriented :-

A modern language is one that provides latest features and tools for developing scalable, reliable, and robust industry–standard applications. C# is a modern language. The current trend in programming is Web development, and C# is the best language for developing web application and components for the Microsoft .NET platform. As mentioned, C# is an object–oriented language. It supports all the basic object oriented language features:-encapsulation, polymorphism, and inheritance.

2. Simple and Flexible:-

C# is as simple to use as Visual Basic, in that everything in C# represented as an object. All data type and components in C# are objects. C++ programmers are sometimes confused when choosing different access operators to process object. With C# you use a dot (.) operator to access the object members. Programmers use C# to develop both managed and unmanaged code. Managed code is code managed through the CLR module. It handles garbage collection, type-safety, and platform-independence behavior. Unmanaged code, on the other hand is code run outside the CLR, such as an ActiveX control. C# provides the flexibility of using native Win 32 application programming interface (API) and unmanaged code through COM+. C# enables you to declare unsafe classes and members having pointers, COM interfaces, structures, and native APIs.

3. Typesafety:-

C# is a typesafe language. All variables and classes (including primitive type, such as integer, Boolean, and float) in C# are a type, and all type are derived from the object the object type. The object type provides basic functionality, such as string conversion, and information about a type. (See “The Object Class” section of this article for more about the object type.) C# doesn’t support unsafe type assignments. In other words, assigning a float variable directly to a Boolean variable is not permitted. If you assign a float type to a Boolean type, the compiler generates an error. C# supports two kinds of type: value type and reference types. All value types are initialized with a value of zero, and all reference types are automatically initialized with a null value (local variable need to be initialized explicitly or the compiler throw a warning).

4. Automatic Memory Management and Garbage Collection:-

Automatic memory management and garbage collection are two important features of C#. With C#, you don’t need to allocate memory or release it. The garbage collection feature ensures that unused references are deleted and cleaned up in memory. You use the new operator to create type object, but you never need to call a delete operator to destroy the object. If the garbage collector finds any unreferenced object hanging around in memory, it removes it for you. Although you can’t call delete directly on an object, you have way to get garbage collector to destroy objects.

5. Versioning Control and Scalable:-

If you’re a Microsoft Window developer, you should be familiar with the expression DLL, which refers to having multiple versions of the same Dynamic Link Library (DLL) and not having backward and forward compatibility. For example, you can’t run programs written in Microsoft Foundation class (MFC) version4.0 on systems with MFC version 3.0 or earlier. This is one of the biggest challengers for a developer, especially if you’re developing MFC applications. C# model is based on namespaces. All interfaces and classes must be bundled under a namespace. A namespace has classes as its members. You can access all the members or just a single member of a namespace. Two separate namespaces can have the same class as their member. C# also supports binary compatibility with a base class. Adding a new method to a base class won’t cause any problems in your existing application. The .NET assemblies contain metadata called manifest. A manifest stores information about an assembly such as its version, locale, and signature. There is no concept of registry entries for handing compatibility. In .NET, you simple put your assembly into one global folder if you want to make it sharable; otherwise, you put it in a private folder for private use only.

6. Language and Cross Platform Interoperability:-

C#, as with all Microsoft .NET supported language, shares a common .NET run-time library. The language compiler generates intermediate language (IL) code, which a .NET supported compiler can read with the help of the CLR. Therefore, you can use a C# assembly in VB.NET without any problem, and vice versa. With the full support of COM+ and .NET framework services, C# has the ability to run on cross-platform systems. The Web-based applications created from .NET use an Extensible Markup Language (XML) model, which can run on multiple platforms.

HOME NEXT