C# (C Sharp) is a modern, general-purpose, and object-oriented Programming Language. C# is developed by Microsoft in the year 2000 and is a part of the Microsoft .NET product. C# is widely used to create cross-platform web apps, desktop apps, games, and much more.
Example: A simple program to print Hello codewithmind
using System;
namespace HelloCWMApp
{
class HelloCWM
{
// Main function
static void Main(string[] args)
{
// Printing Hello codewithmind
Console.WriteLine("Hello CodeWithMind");
Console.ReadKey();
}
}
}
CSharp Introduction
C# is a High-level programming language. This programming language depends on some specific environment, tools, which are essential for development of C#. There are is also a framework and IDE's whose are associated with the development in C# programming Language. Let's look in to them one by one.
.Net SDK
The .NET SDK (Software Development Kit) is a set of libraries and tools that allow developers to create .NET applications. The current version of dotnet which is .Net 6 supports cross-platform development which means that applications built in .Net can run on any operating system, for example, MS Windows, Linux, and macOS.
.Net Framework
.NET Framework is a Windows-only version of .NET for building apps that run on Windows. Different types of applications that can be built using the .Net Framework are Windows Desktop Applications, Web-Based Applications, and Web Services.
Integrated Development Environment
CSharp development can be done in any code editor. One important thing that is a prerequisite is the .Net SDK. After installing the .Net SDK you can start programming in C# even in Notepad. But there are some recommendations from platform provider Microsoft. They recommend to use Microsoft Visual Studio which is an IDE for development. MS Visual Studio Code which is a light weight editor is a perfect choice for programming if one rapid development.
CSharp Fundamentals
C# has a variety of tools, libraries and concepts which made it a powerful modern programming language. Let us list down some of core concepts:
- Classes
- Methods
- Variables
- Comments
- Data Types
- Loops
- Collections
- File IO
- LINQ
- OOP (Object Oriented Programming)
- Garbage Collection
- Design Principles
- Exception Handling
C# History and Major Features with Versions
C# 1.0
- Released in January 2002.
- Basic language features and .NET Framework integration.
- Introduced classes, inheritance, and interfaces.
C# 2.0
- Released in November 2005.
- Added generics, nullable value types, and anonymous methods.
- Introduced partial classes for better code organization.
C# 3.0
- Released in August 2007.
- Introduced LINQ (Language Integrated Query).
- Added automatic properties and anonymous types.
C# 4.0
- Released in April 2010.
- Added optional and named parameters.
- Introduced dynamic types and improved COM interoperability.
C# 5.0
- Released in August 2012.
- Introduced asynchronous programming with the "async" and "await" keywords.
- Added caller info attributes for better debugging.
C# 6.0
- Released in July 2015.
- Added features like string interpolation and null-conditional operators.
- Introduced the nameof expression for safer coding.
C# 7.0
- Released in March 2017.
- Introduced pattern matching, tuples, and local functions.
- Added out variables and deconstruction of tuples.
C# 8.0
- Released in September 2019.
- Introduced nullable reference types for better null safety.
- Added async streams and improved pattern matching.
C# 9.0
- Released in November 2020.
- Introduced records, top-level statements, and improved pattern matching.
- Added new features for performance and code simplification.
C# 10.0
- Released in August 2021.
- Introduced new features like global usings, interpolated string handlers, and file-scoped namespaces.
- Focused on simplifying code and improving readability.
C# 11.0
- Released in August 2022.
- Added support for interpolated strings as format strings for System.FormattableString.
- Improved performance and introduced new syntax features.
C# 12.0
- Released in November 2023.
- Added Primary Constructors
- Collection Expressions
- Introduced Inline Arrays
- Added Optional Parameters in Lambda Expressions
- Introduced ref readonly Parameters
- Added Alias Any Type
- Introduced Experimental Attribute
- Added Interceptors
Tags:
csharp