EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

C# Versions

By Priya PedamkarPriya Pedamkar

Home » Software Development » Software Development Tutorials » C# Tutorial » C# Versions

C# Versions

Introduction to C# Versions

C# is an object-oriented language. It is very simple and powerful. This language is developed by Microsoft. C# first release occurred in the year 2002. Since then below released or versions has come. In this article, we will discuss the different versions.

Versions of C#

Here we will discuss the Versions of C#. Given below are the Versions of C#:

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

1. C# Version 1.0

This version is like java. Its lack in the async capabilities and some functionalities. The major features of this release are below

Classes: It is a blueprint that is used to create the objects.

  • There can be only one public class per file.
  • Comments can appear at the beginning or end of any line.
  • If there is a public class in a file, the name of the file must match the name of the public class.
  • If exists, the package statement must be the first line.
  • import statements must go between the package statement(if there is one) and the class declaration.
  • If there are no package or import statements, the class declaration must be the first line in the source code file.
  • import and package statements apply to all classes within a source code file.
  • File with no public classes can have a name that need not match any of the class names in the file.

Code:

// declaring public class
public class Test
{
// variable
public int a, b;
// member function
public void display()
{
WriteLine(“Class in C#”);
}
}

Structure: In Struct, we can store different data types under a single variable. We can use user-defined datatype in structs. We have to use the struct keyword to define this.

Popular Course in this category
C# Training Program (6 Courses, 17 Projects)6 Online Courses | 17 Hands-on Project | 89+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.6 (8,847 ratings)
Course Price

View Course

Related Courses
ASP.NET Training (8 Courses, 19 Projects).NET Training Program (4 Courses, 19 Projects)

Code:

using System;
namespace ConsoleApplication {
// structure
public struct Emp
{
// different data types
public string Name;
public int Age;
public int Empno;
}
class Geeks {
// Main Method
static void Main(string[] args)
{
// Declare P1 of type Person
Person P1;
// P1's data
P1.Name = "Ram";
P1.Age = 21;
P1.Empno = 80;
// Displaying the values
Console.WriteLine("Data Stored in P1 is " +
P1.Name + ", age is " +
P1.Age + " and empno is " +
P1.empno);
}
}
}

Interfaces:

  • The interface is used as a contract for the class.
  • All interface methods are implicitly public and abstract.
  • All interface variables are public static final.
  • static methods not allowed.
  • The interface can extend multiple interfaces.
  • Class can implement multiple interfaces.
  • Class implementing interface should define all the methods of the interface or it should be declared abstract.

Literals: It is a value used by the variable. This is like a constant value.

Code:

class Test {
// Main method
public static void Main(String []args)
{
int a = 102;
// octal-form literal
int b = 0145
;
// Hexa-decimal form literal
int c = 0xFace;
Console.WriteLine(a);
Console.WriteLine(b);
Console.WriteLine(c);
}
}

Delegates: This is like a pointer. It is a reference type variable which holds the other methods.

2. C# Version 1.2

In this version, some enhancement has been done. They added for each loop in this version which will execute each block until an expression gets false.

3. C# Version 2.0

In this version, they have added below advance features.

Generics: Generic programming is a style of computer programming in which algorithms are written in terms of types to-be-specified-later that are then instantiated when needed for specific types provided as parameters.

Anonymous Method: This is a blank method. This is defined using the keyword delegate.

  • Nullable type: Before this release, we can not define a variable as null. So this release overcomes this.
  • Iterators
  • Covariance and contravariance
  • Getter/setter separate accessibility: We can use a getter setter for getting and setting the values.

4. C# Version 3.0

This version made C# as a formidable programming language.

  • Object and collection initializers: With the help of this we can access any field without invoking constructor.
  • Partial Method: As the name suggests its signature and implementations defined separately.
  • Var: we can define any variable by using the keyword var.

5. C# Version 4.0

The version introduced some interesting features:

Dynamic Binding: This is like method overriding. Here the compiler does not decide the method which to call.

Code:

public class ClassA
{
public static class superclass
{
void print()
{
System.out.println("superclass.");
}
}
public static class subclass extends superclass
{
@Override
void print()
{
System.out.println("subclass.");
}
}
public static void main(String[] args)
{
superclass X = new superclass();
superclass Y= new subclass();
X.print();
Y.print();
}
}

  • Named/Optional Arguments
  • Generic Covariant and Contravariant
  • Embedded Interop Types

Here the major feature was keyword dynamic. It overrides the compiler at run time.

6. C# Version 5.0

In this version, they added two new models for asynchronous programming.

async and await

With these, we easily retrieve information about the context. This is very helpful with long-running operations. In this async enables the keyword await. With the help of await keyword, all the things get asynchronous. So it runs synchronously till the keyword await.

7. C# Version 6.0

This version included below functionalities

  • Static imports
  • Expression bodied members
  • Null propagator
  • Await in catch/finally blocks
  • Default values for getter-only properties
  • Exception filters
  • Auto-property initializers
  • String interpolation
  • name of the operator
  • Index initializers

8. C# Version 7.0

This version has below advantages

Out Variables: This variable is basically used when the method has to return multiple values. The keyword out is used to pass to the arguments.

Other important aspects are

  • Tuples and deconstruction.
  • Ref locals and returns.
  • Discards: These are write-only ready variables. Basically this is used to ignore local variables.
  • Binary Literals and Digit Separators.
  • Throw expressions
  • Pattern matching: We can use this on any data type.
  • Local functions: With the help of this function we can declare the method in the body which is already defined in the method.
  • Expanded expression-bodied members.

So every version has included new features in the C# which help the developers to solve the complex problems in efficient manner. The next release will be C# 8.0.

Recommended Articles

This is a guide to C# Versions. Here we discuss the basic concept, various types of C# Versions along with examples and code implementation. You can also go through our other suggested articles –

  1. Palindrome in C#
  2. C# Literals
  3. C# Nullable
  4. Operator Overloading in C#

C# Training Program (6 Courses, 17 Projects)

6 Online Courses

17 Hands-on Project

89+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
C sharp Tutorial
  • Basic
    • Uses Of C#
    • C# Versions
    • C# Data Types
    • Variables in C#
    • Namespaces in C#
    • C# Compilers
    • C# Keywords
    • Iterators in C#
    • Objects in C#
    • C# Object Dispose
    • C# object to XML
    • C# check object type
    • C# Object Serialization
    • Pointers in C#
    • C# Literals
    • C# Commands
    • C# Custom Attribute
    • Type Casting in C#
    • String vs String C#
    • C# Struct vs Class
  • Operators
    • Logical Operators in C#
    • Conditional Operators in C#
    • Bitwise Operators in C#
    • C# OR Operator
    • C# Ternary Operators
    • Operator Precedence in C#
  • Control Statement
    • C# if Statement
    • Else If in C#
    • Continue in C#
    • Break in C#
    • Switch Statement in C#
    • Goto Statement in C#
  • Loops
    • C# For Loop
    • C# While Loop
    • C# do-while loop
    • C# foreach Loop
  • Arrays
    • Arrays in C#
    • 2D Arrays in C#
    • C# Jagged Arrays
    • String Array in C#
    • C# Multidimensional Arrays
  • Constructor and Destructor
    • Constructor in C#
    • Copy Constructor in C#
    • Static Constructor in C#
    • Destructor in C#
  • overloading and overrideing
    • Overloading and Overriding in C#
    • Overloading in C#
    • Overriding in C#
    • Method Overloading in C#
    • Method Overriding in C#
    • Operator Overloading in C#
  • Functions
    • C# Functions
    • C# String Functions
    • Math Functions in C#
    • Recursive Function in C#
    • C# Anonymous Functions
    • C# Local Functions
    • Enum in C#
    • Trim() in C#
    • clone() in C#
    • C# random
    • C# String Format()
    • C# String Interpolation
    • C# StartsWith()
    • C# String IndexOf()
    • DateTime in C#
    • C# Nullable
    • C# nameof
    • C# checked
    • C# String PadLeft
    • Convert String to Double in C#
    • Convert int to String C#
    • String to Date C#
    • C# intern()
    • C# Stopwatch
    • C# DirectoryInfo
    • C# Compare()
    • C# Base
    • C# SOAP
    • Lock in C#
  • Advanced
    • Inheritance in C#
    • Exception Handling in C#
    • Types of Exception in C#
    • C# FileNotFoundException
    • C# NullReferenceException
    • C# OutOfMemoryException
    • C# StackOverflowException
    • Custom Exception in C#
    • What is Multithreading in C#
    • C# finally
    • C# System.IO
    • What is StringBuilder in C#
    • DataReader C#
    • BinaryWriter in C#
    • C# BinaryReader
    • TextWriter in C#
    • TextReader in C#
    • C# StringReader
    • C# StringWriter
    • C# StreamReader
    • C# StreamWriter
    • C# FileInfo
    • What is Design Pattern in C#?
    • Multithreading in C#
    • Sorting in C#
    • Bubble Sort in C#
    • C# SortedList
    • C# SortedSet
    • C# SortedDictionary
    • Abstract Class in C#
    • Access Modifiers in C#
    • C# Generics
    • Deserialization in C#
    • C# Thread
    • C# Thread Join
    • C# Thread Sleep
    • C# Thread Synchronization
    • C# Class
    • Sealed in C#
    • Sealed Class in C#
    • Polymorphism in C#
    • C# Call By Reference
    • Virtual Keyword in C# 
    • Yield Keyword in C#
    • Regular Expression in C#
    • C# Lambda Expression
    • C# Predicate
    • Convert Object to JSON C#
    • Checkbox in C#
    • C# MessageBox
    • Collections in C#
    • List in C#
    • C# LinkedList
    • Listbox in C#
    • Protected in C#
    • C# EventHandler
    • Private in C#
    • this Keyword in C#
    • Static Keyword in C#
    • C# Out Parameter
    • Assert in C#
    • C# Delegates
    • C# Interface
    • Generics in C#
    • Timer in C#
    • C# Serialization
    • Metadata in C#
    • C# Stack
    • C# Using Static
    • Queue in C#
    • C# File.Exists
    • C# Tuples
    • C# Create JSON Object
    • Partial in C#
    • C# readonly
    • C# Action Delegate
    • C# Await Async
    • C# Dictionary
    • IEnumerable C#
    • C# Data Grid View
    • C# Dynamic
    • Web Services in C#
    • C# Pattern Matching
    • C# Extension Methods
    • C# XmlSerializer
  • Programs
    • Patterns in C#
    • Swapping in C#
    • Palindrome in C#
    • Factorial in C#
    • Fibonacci Series in C#
    • Random Number Generator in C#
    • Prime Numbers in C#
    • Armstrong Number in C#
    • Reverse String in C#
  • Interview questions
    • C# Interview Questions and Answers
    • C# OOP Interview Questions
    • C# Design Pattern Interview Questions

Related Courses

C# Certification Training

ASP.NET Course

.NET Course

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - C# Training Program (6 Courses, 17 Projects) Learn More