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 Algorithms, Pseudocode, Programs, and Flowcharts 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?
What is C#?
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# was developed by Anders Hejlsberg and his team during the development of the .Net Framework. C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows the use of various high-level languages on different computer platforms and architectures. The following reasons make C# a widely used professional language −
- It is a modern, general-purpose programming language
- It is object-oriented.
- It is component-oriented.
- It is easy to learn.
- It is a structured language.
- It produces efficient programs.
- It can be compiled on a variety of computer platforms.
- It is a part of the .Net Framework.
Features of C#
Although C# constructs closely follow traditional high-level languages, C and C++ and being an object-oriented programming languages. 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# −
- 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.
- 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.
- 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.
- 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.
- Interoperability: The interoperability process enables the C# programs to do almost anything that a native C++ application can do.
- 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.
- 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.
- 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.
- Rich Library: C# provides a lot of inbuilt functions that make the development fast.
- 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:
- Window applications
- Web applications
- Distributed applications
- Web service applications
- Database applications etc.
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.
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.
It is based on C++ and Java, but it has many additional extensions used to perform component-oriented programming approaches. C# has evolved much since its first release in the year 2002. It was introduced with .NET Framework 1.0 and the current version of C# is 5.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#:
.NET Framework: .NET Framework 1.0/1.1
Visual Studio: Visual Studio .NET 2002
- Basic features
.NET Framework: NET Framework 2.0
Visual Studio: Visual Studio 2005
- Partial types
- Anonymous methods
- Nullable types
- Private setters (properties)
- Method group conversions (delegates)
- Covariance and Contra-variance
- Static classes
.NET Framework: .NET Framework 3.0\3.5
Visual Studio: Visual Studio 2008
- Implicitly typed local variables
- Object and collection initializers
- Auto-Implemented properties
- Anonymous types
- Extension methods
- Query expressions
- Lambda expressions
- Expression trees
- Partial Methods
.NET Framework: .NET Framework 4.0
Visual Studio: Visual Studio 2010
- Dynamic binding (late binding)
- Named and optional arguments
- Generic co- and contravariance
- Embedded interop types
.NET Framework: .NET Framework 4.5
Visual Studio: Visual Studio 2012/2013
- Async features
- Caller information
.NET Framework: .NET Framework 4.6
Visual Studio: Visual Studio 2013/2015
- Expression Bodied Methods
- Auto-property initializer
- nameof Expression
- Primary constructor
- Await in the catch block
- Exception Filter
- String Interpolation
.NET Framework: .NET Core 2.0
Visual Studio: Visual Studio 2017
- Out Variables in C#
- Pattern Matching in C#
- Digit Separators in C#
- Tuples in C#
- Splitting Tuples in C#
- Local Functions in C#
- Ref Returns and Ref Locals in C#
- Generalized Async Return Types in C#
- Expression Bodied Members in C#
- Thrown Expression in C#
- Async Main in C#
.NET Framework: .NET Core 3.0
Visual Studio: Visual Studio 2019
- Default interface methods
- Nullable reference types
- Pattern matching enhancements
- Asynchronous streams / Asynchronous disposable
- Using declarations
- Enhancement of interpolated verbatim strings
- Null-coalescing assignment
- Static local functions
- Indices and ranges
- Unmanaged constructed types
- Stackalloc in nested expressions
- Disposable ref structs
.NET Framework: .NET 5.0
Visual Studio: Visual Studio 2019
- Top-level statements
- Record types
- Init-only setters
- Enhancements to pattern matching
- Natural-sized integers
- Function pointers
- Target type new
- Target type conditional
- Static anonymous methods
- Covariant return types
- Lambda discard parameters
- Attributes on local functions
.NET Framework: .NET 6.0
Visual Studio: Visual Studio 2022
- Record structs
- Improvements in structure types
- Interpolated string handlers
- global using directives
- File-scoped namespace declaration
- Extended property patterns
- Improvements in lambda expressions
- Allow const interpolated strings
- Record types can seal ToString()
- Improved definite assignment
- Allow both assignment and declaration in the same deconstruction
- Allow AsyncMethodBuilder attribute on methods
- CallerArgumentExpression attribute
- Enhanced #line pragma
What can C# do for us?
Well, the answer is, a lot. I would say, nearly anything. Unless you’re writing non-Microsoft platform-centric code, C# can pretty much 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.
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.
- Cloud-native apps and services
- Windows client applications
- Windows libraries and components
- Windows services
- Web applications
- Web services and Web API
- Native iOS and Android mobile apps
- Backend services
- Azure cloud applications and services
- Backend database using ML/Data tools
- Interoperability software such as Office, SharePoint, SQL Server and so on.
- Artificial Intelligence and Machine learning
- Blockchains and distributed ledger technology including cryptocurrency
- Internet of Things (IoT) devices
- Gaming consoles and gaming systems
- Video games
In the next article, I am going to discuss .NET Framework Architecture and Components. 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.