Nice reference for C# evolution

Csharp
Csharp

Nice reference for C# evolution

Welcome to CodeSpread!

While going through some posts on MSDN, I came across this beautiful image which can be termed as a one stop solution for C# evolution. This is a gift reference, I would like to share with my friends and readers and I know, this will help them like it helped me. This is a revisit to all the steps which are required to know our growth as a C# Developer.

Although, Matrix is very much clear on its own but we can revisit the concepts one more time.

csharpevolution

csharpevolution

C# 1.0

Managed Code

Before that, We should know Unmanaged Code.

Unmanaged Code: Unmanaged code is compiled to machine code and therefore executed by the Operating System directly.It is sometimes referred to as Native Code. Unmanaged executable files are basically a binary image, x86 code, loaded into memory.It is compiled and run directly on the processor it was designed for.It is fast and simple. As it interacts directly with operating system so this is always considered damaging and unsecured plus there are many factors like type safety checking, memory management, and destruction of unneeded objects that are additional tasks required to be performed.

Managed Code: Managed code is code that has its execution managed by the .NET Framework Common Language Runtime. It does not interact directly with the Operating System or machine but this code gets converted to an intermediate language with the help of CLR. When we run the code,just before that, the IL is compiled into native executable code. CLR enforces managed execution environment that ensures type safety, array bound and index checking, exception handling, and garbage collection.The idea behind is to provide a secure environment or framework for development which interacts with the machine or operating system through a defined boundary.

 

C# 2.0

Generics

Generic Class:

We are talking reusability here. We got bored of creating similar classes again and again so we thought of creating type independent class and C# guided with their generics feature. Generics helped us to create classes that can take any type and at the point of instantiation, type can be provided to the class to make it one specialized class. With Generics,There is no need to create same kind of class for different types then.

Example

Before generics


public class Products

{

private int _productid;

private ListGetProducts()

{

//Implementation

}

}

//One more class

public class Category

{

private int _categoryid;

private ListGetCategory()

{

//Implementation

}

}

If we look at these classes, then we can easily identify that these can be changed to a  generic class. Here, List<> is a collection.

Now after applying Generics.


public class Generics<T>

{

private int _genericid;

private List<T> Get<T>()

{

//Implementation

}

}

Here, T identifies the type that is going to be provided while instantiating the class like


Generics<Product> generics= new Generics<Product>();

Note: Generic class provide runtime type safety.

Generic Collections:

We can use collections with generics and take advantages like

  1. Compile time creation of type safe collection.
  2. Code reusability
  3. Improved Performance
  4. Avoid Boxing ad Unboxing
  5. Strong Type Checking

Example


ListstringList= new List();

Anonymous Methods

Anonymous methods can be termed as an extension of delegates. Delegates is a very broad topic and requires one article in itself so we will explain later.

RIght Now,Anonymous methods can be used in the place where there is a use of a delegate so lets write a delegate.


 

//Declare a delegate

delegate void DelegateExample();

//Declare method following delegate signature

void Example1(){//Implementation

}

//Create instance of delegate and wrap the function

DelegateExample delegateExample = new DelegateExample(Example1);

//Or

DelegateExample delegateExample = Example1;

//Finally call the instance

delegateExample();

Now, we will change the delegate instantiation to accommodate anonymous method


//Declare a delegate

delegate void DelegateExample();

//Create instance of delegate and wrap the function without any function name

DelegateExample delegateExample =

delegate(){

//Example1 Implementation

}

//Finally call the instance

delegateExample();

Nullable Types

Refer this article

We will talk about rest of the feature in next article.

Author: hershey

A passion for knowledge drives me to do programming, A passion for programming drives me to create something different, A passion for creation drives me to spread the knowledge.

Share This Post On

0 Comments

  1. nice superb explaination

    Post a Reply
  2. thanks for the tutorial
    I am having a problem.
    The feature “Create SQL server database” isn’t available , I can’t select it.
    Can you help, please ?

    Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

More from CodeSpread:

  • Agile Encounters UnpredictabilityAgile Encounters UnpredictabilityWhat is Agile? Wikipedia says “Agile software development is a group of software development methods based on iterative and incremental development, where requirements and solutions evolve through...
  • Nice reference for C# evolution Part 4Nice reference for C# evolution Part 4We completed till C# 4.0 introductions in last article,C# 3.0 in this article and C# 2.0 in first article . We will forward our journey with C# 5.0 features. C# 5.0 Async Feature There are new m...
  • Nice reference for C# evolution Part 3Nice reference for C# evolution Part 3We completed till C# 3.0 introductions in last article and C# 2.0 in this article . We will forward our journey with C# 4.0 features. C#4.0 Late Binding (Dynamic) Late binding is always presumed...
  • Get Educated: C# language 5.0 SpecificationsGet Educated: C# language 5.0 SpecificationsVery often,Developers ask me to write something about C# Language Specifications and I always ask them to refer Microsoft Download center. I think this is a pretty easy act as C# Language Specifica...
  • Nice reference for C# evolution Part 2Nice reference for C# evolution Part 2We completed till C# 2.0 introductions in last article. We will forward our journey with C# 3.0 features. C# 3.0 Lambda Expressions: Last article, we discussed anonymous function and how they ex...
  • Concepts: S O L I DConcepts: S O L I DSOLID - Object oriented programming principles. May be its easy to forget these principles  but for creating a reusable code or maintainable code, people will always have to come back and check ...
  • C# Code to send a MailC# Code to send a MailWhile working in a project, we always neglect the importance of the code which we have written many times and now end up in copy pasting the code from old projects. Lately, I saw a request in fo...
  • C#: Singleton Design PatternC#: Singleton Design PatternWe know the existence of a design pattern is dependent on a recurring problem. Once the problem is identified, then a well established solution is proposed theoretically and different implementatio...