Skip to content

fabioono25/csharpstudy

Repository files navigation

What is the C# History?

The C# History is a compound of examples that can show how the language was growing during the years. It'll start with the basic concepts of an Oriented-Programming Language, until newer and better features.

How to use the material

For each version of the language we have a folder containing the examples. It'll have examples and comments so be free to copy and use as reference.

You can see the series containing articles about the main features throught the history of this language in the blog [My Life in Dev].(https://www.mylifeindev.com/)

If you like it! ⭐

If you liked the examples, give a star!

About C#

C# is an object-oriented language that was born in 2002, with the strategy of Microsoft to provide a more robust and strongly typed language. To achieve this, the idea was following some design goals defined by ECMA.

Design goals from ECMA for C#:

  • intended to be simple, modern, general purpose, OOP;
  • strongly type checking, array bound checking, check unitialized variables;
  • automatic garbage collection;
  • distributed environments;
  • programmer portability;
  • support to internationalization;
  • suitable for both hosted and embedded systems.

During these more than 15 years, the language is gaining new improvements. Here are the versions:

Version 1.0:

  • Classes and Objects
  • Inheritance
  • Encapsulation
  • Polymorphism
  • Memory Management:
    • Manage execution: automatic memory management and the concept of garbage collection. Value objects are allocated on the stack, while reference ones are part of the heap. GC traverses the object graph (Marking Phase) and then scans the entire heap for unmarked objects (Sweeping Phase). The objects are divided in different generations, based on their lifetime:
      • Generation 0: Contains short-lived objects that are typically created and collected quickly.
      • Generation 1: Contains objects that have survived one garbage collection cycle.
      • Generation 2: Contains long-lived objects that have survived multiple garbage collection cycles.
    • It is important to stress that GC doesn't handled the cleanup of some resources, like DB connections or network sockes. This is why we have IDisposable interface and using statements.
  • Exceptions
  • Delegates: are used to define a type that represents a reference to a method or a group of methods. They provide a way to encapsulate and pass methods as parameters or store them in variables, enabling callbacks and dynamic invocation of methods. Advantages:
    • decoupling of components.
    • flexibility and extensibility
    • functional programming
    • async programming
    • customizations
  • Events: build upon delegates and are used to provide a standardized way of implementing the publisher-subscriber pattern. They allow objects to notify other objects when certain actions or states occur, facilitating event-driven programming.
  • Arrays
  • Iteration Statements
  • Conditional Staments
  • Structs
  • Enums
  • Value Types
  • Reference Types
  • Boxing and Unboxing
  • Attributes
  • Interfaces
  • ForEach Support for IDisposable
  • Reflection
  • Unsafe
  • Check and Uncheck
  • Constructors and Destructors:
    • Constructors:

      • Constructors are special methods that are called when an instance of a class or struct is created.
      • They have the same name as the class or struct and do not have a return type (not even void).
      • Constructors can have parameters to accept values for initializing the object's state.
      • Constructors can be overloaded, allowing different ways to create instances of the class or struct.
      • If a class does not define any constructors, a default constructor is automatically generated by the compiler, which initializes the object with default values.
      • Constructors can perform initialization tasks, such as setting default values, allocating resources, or validating input parameters.
    • Destructors:

      • Destructors, also known as finalizers, are special methods that are automatically called by the garbage collector when an object is being finalized.
        • They are used to release unmanaged resources or perform other cleanup tasks before the object is destroyed.
        • Destructors are defined using the ~ symbol followed by the class name.
        • Destructors cannot be called explicitly or overloaded.
        • The execution order of destructors is non-deterministic, as it depends on the garbage collector's collection cycle.
        • It's generally recommended to implement the IDisposable interface and use the Dispose() method to release resources explicitly instead of relying solely on destructors.
    • Using keyword Version 2.0- Generics

  • Partial Types
  • Anonymous Methods
  • Nullable Value Types
  • Iterators
  • Covariance and Contravariance
  • Getters and Setters Accessibility
  • Delegate Inference
  • Static Classes

Version 3.0

  • Auto-Implemented Properties
  • Anonymous Types
  • Query Expressions
  • Lambda Expressions
  • Expression Trees
  • Extension Methods
  • Implicit Typed Local Variables
  • Partial Methods
  • Objects Colections Initializers

Version 4.0

  • Named Arguments
  • Optional Parameters
  • Dynamics
  • Covariance and Contravariance for Generic Types

Version 5.0

  • CallerInfoAttributes
  • Asynchronous Methods

Version 6.0

Version 7.0

Version 8.0

Version 9.0

Resources

C# Fundamentals for Beginners

C# Guide - Fundamentals (MSDN)

Top 85 C# Interview Questions and Answers for 2024

C# Interview Questions

About

There are a plenty of algorithms about C# - from simple to advances (C# version 10 in .NET 6)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published