Introduction to C# Programming Language

Introduction to C# Programming Language

In this article, I am going to give a brief introduction to C# Programming Language. Please read our previous article where we discussed .NET Framework Architecture and Components in detail. At the end of this article, you will understand mostly What is C#, Features of C#. What are the different types of applications developed using C#, C# version history, and what C# can do for us?

Why did C#.NET come to the market?

C#.NET Programming Language is mainly designed to overcome the disadvantages of C and C++ and to develop internet applications (web applications) by achieving platform independence.

Why C# is so much popular nowadays?

C#.NET is so much popular nowadays because of the following reasons.

C# is Simple and Familiar:

C# is simple because C# simplifies the programmer’s job by avoiding certain features of C and C++. C# avoids explicit memory management. Memory management in C# is automatic. It is done by CLR. So, there is no chance of memory leakage. There is pointer concept in C# but it is restricted. C# is very familiar to programmers because it is modeled on the C and C++ languages. C# uses many features of C and C++; therefore, C# codes look like C and C++ codes. We can say C# is the simplified version of C and C++.

C# is Portable:

Portability allows the programmer to write the same code for different machines (operating systems). C# provides portability in two ways

  1. Source Code portability
  2. IL Code portability

In C#, we can write the source code as well as the IL code in different Operating Systems and also get the output. Whereas in the case of C and C++ there is only source code portability.

C# is Architecturally Neutral:

The behavior of C# programs doesn’t change when we move from one system to another which means it will provide the same output in every machine because in C# memory layout decisions are not made at compile time, it is made at run time by CLR. But in the case of C and C++ programs, the behavior changes when we move the program from one system to another.

C# is Secured:

C# is secured because the C# programs are executed in a secured environment called CLR. CLR will provide security to the C# programs.

C# is Robust:

Robust means strong. C# is a strongly type checking language having strict type checking during both compilation time and execution time which allows us to develop both error-free applications and programs.

C# is Distributed:

Using C# Programming Language, we can develop distributed applications whose resources are shared by more than one client. An application or program whose resources are shared by more than one client is called a distributed application. As C# is used for developing such applications. So, C# is a distributed programming language.

C# is Multithreaded:

A process is divided into several small parts known as threads or lightweight processes. Sending multiple threads to the processor for processing is known as multi-threading. Multi-threading means handling multiple tasks simultaneously. For example, we can listen to music while scrolling a page and at the same time we can download an application from the internet on a computer. C# supports multithreaded programming.

C# is Dynamic:

The link between the function call and function definition is called binding. There are two types of binding

  1. Static binding
  2. Dynamic binding

When a method is invoked, if its method definition which is bound at compilation time by the compiler is only executed by CLR at run time, then it is called compile-time polymorphism or static binding, or early binding.

When a method is invoked, the method definition which is bound at compilation time by the compiler is not executed at run time by CLR, instead, it is executed from the subclass based on the object stored in the referenced variable called run time polymorphism/dynamic binding. So, C# is dynamic.

C# is Compiled and Interpreted:

We know a programming language is either compiled or interpreted. But C# combines both approaches. That’s why C# is called a two-stage system.

First C# compiler CSC translates source code into an intermediate language code known as MSIL (Microsoft Intermediate Language) code. But these IL codes are not machine instructions. So, in the second stage, this IL code is interpreted by the C# interpreter (One Component of CLR). As a result, machine instructions will be generated which are directly executed by the machine. Hence, we are saying C# is both interpreted and compiled language.

C# is Object-Oriented:

Except for the primitive data types, all elements in C# are objects. Object-oriented is not a programming language, it is a programming technique or concept, or principle which defines a set of rules and regulations for organizing the data and instructions. The concepts provided by oops are as follows

  1. Encapsulation
  2. Abstraction
  3. Polymorphism
  4. Inheritance

The programming language supports these four features known as an object-oriented programming language. C# supports these four features so C# is object-oriented.

C# is Platform Independent:

Many languages are compatible with only one platform. Now, with the introduction of .NET Core and .NET, C# was specifically designed to be platform independent, so that it would run on any computer. C# applications can be run on Windows, Linux, and Mac operating systems.

Automatic Memory Management:

.NET Framework manages memory allocation and de-allocation for creating new objects. The program does not have direct access to memory. The so-called garbage collector automatically deletes objects to which no active pointer exists.

C# Definition based on the above features:

C# is just a simple, secure, robust, portable, platform-independent, architectural neutral, multithreaded, object-oriented programming language with a strong type exception handling mechanism for developing different kinds of applications such as Web, Windows Form, Console, Web Services, Mobile Apps, etc.

C# is pronounced as “C-Sharp”. It is an object-oriented programming language provided by Microsoft that runs on the .Net Framework. C# is a modern, general-purpose, object-oriented programming language developed by Microsoft and approved by European Computer Manufacturers Association (ECMA) and International Standards Organization (ISO).

C# is approved as a standard by ECMA and ISO. C# is designed for CLI (Common Language Infrastructure). CLI is a specification that describes executable code and runtime environment. The C# programming language is influenced by C++, Java, Eiffel, Modula-3, Pascal, etc. Languages.

Features of C#

Although C# constructs closely follow traditional high-level languages, C and C++ and being an object-oriented programming language. It has a strong resemblance with Java, it has numerous strong programming features that make it endearing to a number of programmers worldwide. Following is the list of a few important features of C# −

  1. Simple: C# is a simple language in the sense that it provides a structured approach (to break the problem into parts), a rich set of library functions, data types, etc.
  2. Modern Programming Language: C# programming is based upon the current trend and it is very powerful and simple for building scalable, interoperable, and robust applications.
  3. Object-Oriented: C# is an object-oriented programming language. OOPs makes development and maintenance easier whereas in Procedure-oriented programming language it is not easy to manage if code grows as the project size grows.
  4. Type-Safe: C# type safe code can only access the memory location that it has permission to execute. Therefore, it improves the security of the program.
  5. Interoperability: The interoperability process enables the C# programs to do almost anything that a native C++ application can do.
  6. Scalable and Updateable: C# is an automatic scalable and updateable programming language. For updating our application, we delete the old files and update them with new ones.
  7. Component Oriented: C# is a component-oriented programming language. It is the predominant software development methodology used to develop more robust and highly scalable applications.
  8. Structured Programming Language: C# is a structured programming language in the sense that we can break the program into parts using functions. So, it is easy to understand and modify.
  9. Rich Library: C# provides a lot of inbuilt functions that make the development fast.
  10. Fast Speed: The compilation and execution time of the C# language is fast.
Types of Applications Developed using C#:

With the help of the C# programming language, we can develop different types of secured and robust applications:

  1. Window applications
  2. Web applications
  3. Distributed applications
  4. Web service applications
  5. Database applications
  6. Mobile Applications, etc
C# History

The history of the C# language is interesting to know. C# is pronounced as “C-Sharp”. It is an object-oriented programming language provided by Microsoft that runs on the .Net Framework. Anders Hejlsberg is known as the founder of the C# language.

Introduction to C# Programming Language

It is based on C++ and Java, but it has many additional extensions used to develop different types of Applications. C# was first release in the year 2002. It was introduced with .NET Framework 1.0 and the current version of C# is 10.0. Let’s see the important features introduced in each version of C# are given below.

C# Version History

C# was first introduced with .NET Framework 1.0 in the year 2002 and evolved much since then. The following table lists important features introduced in each version of C#:

C# 1.0:

.NET Framework: .NET Framework 1.0/1.1

Visual Studio: Visual Studio .NET 2002

Important Features:

  1. Basic features
C# 2.0

.NET Framework: NET Framework 2.0

Visual Studio: Visual Studio 2005

Important Features:

  1. Generics
  2. Partial types
  3. Anonymous methods
  4. Iterators
  5. Nullable types
  6. Private setters (properties)
  7. Method group conversions (delegates)
  8. Covariance and Contra-variance
  9. Static classes
C# 3.0

.NET Framework: .NET Framework 3.0\3.5

Visual Studio: Visual Studio 2008

Important Features:

  1. Implicitly typed local variables
  2. Object and collection initializers
  3. Auto-Implemented properties
  4. Anonymous types
  5. Extension methods
  6. Query expressions
  7. Lambda expressions
  8. Expression trees
  9. Partial Methods
C# 4.0

.NET Framework: .NET Framework 4.0

Visual Studio: Visual Studio 2010

Important Features:

  1. Dynamic binding (late binding)
  2. Named and optional arguments
  3. Generic co- and contravariance
  4. Embedded interop types
C# 5.0

.NET Framework: .NET Framework 4.5

Visual Studio: Visual Studio 2012/2013

Important Features:

  1. Async features
  2. Caller information
C# 6.0

.NET Framework: .NET Framework 4.6

Visual Studio: Visual Studio 2013/2015

Important Features:

  1. Expression Bodied Methods
  2. Auto-property initializer
  3. nameof Expression
  4. Primary constructor
  5. Await in the catch block
  6. Exception Filter
  7. String Interpolation
C# 7.0

.NET Framework: .NET Core 2.0

Visual Studio: Visual Studio 2017

Important Features:

  1. Out Variables in C#
  2. Pattern Matching in C#
  3. Digit Separators in C#
  4. Tuples in C#
  5. Splitting Tuples in C#
  6. Local Functions in C#
  7. Ref Returns and Ref Locals in C#
  8. Generalized Async Return Types in C#
  9. Expression Bodied Members in C#
  10. Thrown Expression in C#
  11. Async Main in C#
C# 8.0

.NET Framework: .NET Core 3.0

Visual Studio: Visual Studio 2019

Important Features:

  1. Default interface methods
  2. Nullable reference types
  3. Pattern matching enhancements
  4. Asynchronous streams / Asynchronous disposable
  5. Using declarations
  6. Enhancement of interpolated verbatim strings
  7. Null-coalescing assignment
  8. Static local functions
  9. Indices and ranges
  10. Unmanaged constructed types
  11. Readonly-Member
  12. Stackalloc in nested expressions
  13. Disposable ref structs
C# 9.0

.NET Framework: .NET 5.0

Visual Studio: Visual Studio 2019

Important Features:

  1. Top-level statements
  2. Record types
  3. Init-only setters
  4. Enhancements to pattern matching
  5. Natural-sized integers
  6. Function pointers
  7. Target type new
  8. Target type conditional
  9. Static anonymous methods
  10. Covariant return types
  11. Lambda discard parameters
  12. Attributes on local functions
C# 10.0

.NET Framework: .NET 6.0

Visual Studio: Visual Studio 2022

Important Features:

  1. Record structs
  2. Improvements in structure types
  3. Interpolated string handlers
  4. global using directives
  5. File-scoped namespace declaration
  6. Extended property patterns
  7. Improvements in lambda expressions
  8. Allow const interpolated strings
  9. Record types can seal ToString()
  10. Improved definite assignment
  11. Allow both assignment and declaration in the same deconstruction
  12. Allow AsyncMethodBuilder attribute on methods
  13. CallerArgumentExpression attribute
  14. Enhanced #line pragma
What can C# do for us?

Well, the answer is, a lot. I would say, nearly anything. C# can be used to write Windows clients Applications, Web applications, Mobile Apps, Enterprise Software, Backend, and Service-Oriented Applications. The following image demonstrates the C# world and applications ecosystem. The following image demonstrates the C# world and applications ecosystem.

C# Applications Ecosystem

As you can see from the above image, the C# language can be used to build any and all kinds of applications. Not only Windows or Web applications but C# can be used to build mobile, Windows Store, and Enterprise applications. C# can also be used within the SQL Server database to build reports, jobs, and modules to do the backend work. Here is a list of types of applications C# can develop.

  1. Cloud-native apps and services 
  2. Windows client applications
  3. Windows libraries and components
  4. Windows services
  5. Web applications
  6. Web services and Web API
  7. Native iOS and Android mobile apps
  8. Backend services
  9. Azure cloud applications and services
  10. Backend database using ML/Data tools
  11. Interoperability software such as Office, SharePoint, SQL Server, and so on.
  12. Artificial Intelligence and Machine learning
  13. Blockchains and distributed ledger technology including cryptocurrency
  14. Internet of Things (IoT) devices
  15. Gaming consoles and gaming systems
  16. Video games

In the next article, I am going to discuss How to Download and Install Visual Studio on Windows. Here, in this article, I try to give a brief introduction to C# Language. and I hope you enjoy this Introduction to C# Language article.

Leave a Reply

Your email address will not be published.