C Sharp

C# Tutorials

C# (C sharp) is an object-oriented programming language based on C++ and contains features similar to those of Java. C# is designed to work with Microsoft's .Net platform. The most recent version is C# 7.0 which was released in January 2016.

Object Oriented Programming

The goals of this tutorial are to guide you through the terminology of object-oriented programming (OOP) and to give you an understanding of the importance of object-oriented concepts to programming.

Microsoft .NET

Without a firm understanding of .NET and how the C# language plays into this Microsoft initiative, you won't fully comprehend some of the core elements of C# that are supported by the .NET runtime.

Hello, C#

In this tutorial, we'll take a quick tour of the development process for a simple C# application. First, we'll cover the advantages and disadvantages of the different editors to write in C#, write the canonical "Hello, World" example application to get to know the basic syntax and structure of writing C# applications. You'll then learn how to compile using the command-line compiler.

The Type System

In this tutorial, we'll look at new type system. We'll look at how .NET divides types into the two categories, value types and reference types, and we'll discover how boxing enables a completely object-oriented type system to function efficiently. Finally, we'll cover how type casting works in C#, and we'll start looking at namespaces.

Classes

In this tutorial, we'll read the basics of defining classes in C#, including instance members, access modifiers, constructors, and initialization lists, and then we'll move on to defining static members and the difference between constant and read-only fields. After that, we'll cover destructors and something called deterministic finalization.Finally, the tutorial will wrap up with a quick discussion of inheritance and C# classes.

Methods

You'll discover the ref and out method parameter keywords and how they enable you to define a method such that it can return more than a single value to the caller. You'll learn how to define overloaded methods so that multiple methods with the same name can function differently depending on the types and/or number of arguments passed to them. Then you'll learn how to handle situations in which you don't know the exact number of arguments a method will have until run time. Finally, discussion of virtual methods and how to define static methods.

Properties, Arrays, and Indexers

You'll learn about properties, arrays, and indexers because these language features share a common bond. They enable you, the C# class developer, to extend the basic class/field/method structure of a class to expose a more intuitive and natural interface to your class's members.

Attributes

What attributes allow you to do is nothing short of groundbreaking. They provide you a generic means of associating information (as annotations) with your defined C# types. You can use attributes to define design-time information (such as documentation information), run-time information (such as the name of a database column for a field), or even run-time behavioral characteristics (such as whether a given member is "transactionable"?that is, capable of participating in a transaction).

Interfaces

Interfaces enable you to define behavioral characteristics, or abilities, and apply those behaviors to classes irrespective of the class hierarchy.

Expressions and Operators

In this tutorial, we'll take a look at the most basic part of any programming language: its ability to express assignments and comparisons through the use of operators. We'll look at what operators are and how operator precedence is determined in C#, and then we'll delve into specific categories of expressions for doing such things as performing math, assigning values, and making comparisons between operands.

Program Flow Control

The statements that enable you to control program flow in a C# application fall into three main categories: selection statements, iteration statements, and jump statements. In each of these cases, a test resulting in a Boolean value is performed and the Boolean result is used to control the application's flow of execution. In this tutorial, you'll learn how to use each of these statement types to control structure flow.

Error Handling with Exceptions

In this tutorial, you'll learn the general mechanics and basic syntax of exception handling, how exception handling compares with the more prevalent methods of error handling today and you'll discover the advantages that exception handling. We'll also learn .NET exception-handling issues, such as using the Exception class and deriving your own exception classes and issue of properly designing your system to use exception handling.

Operator Overloading and User-Defined Conversions

In this tutorial, we'll look at two closely related features of C# that provide the ability to create structure and class interfaces that are easier and more intuitive to use: operator overloading and user-defined conversions.

Delegates and Event Handlers

In this tutorial, we'll be looking at delegates, how they compare to interfaces, the syntax used to define them, and the different problems that they were designed to address. We'll also see several examples of using delegates with both callback methods and asynchronous event handling.

Multithreaded Programming

This tutorial cover the basics and even some intermediate-to-advanced issues regarding the aborting, scheduling, and lifetime management of threads and also discuss thread synchronization with the System.Monitor and System.Mutex classes and the C# lock statement.

Querying Metadata with Reflection

This tutorial will describe the reflection API and how you can use it to iterate through an assembly's modules and types and to retrieve the different design-time characteristics of a type. You'll also see several advanced usages of reflection, such as dynamically invoking methods and use type information (through late binding) and even creating and executing MSIL code at run time.

Interoperating with Unmanaged Code

Unmanaged code refers to code that is not managed, or controlled, by the .NET runtime. This tutorial cover the three main examples of unmanaged code in .NET: Platform Invocation Services, Unsafe code , COM interoperability.

Working with Assemblies

This tutorial describes the major advantages of using assemblies, including the packaging and versioning of your .NET components.