C# Progamming – Course Outline

(4 days – RAT803)

 

C# is the key language for Microsoft's .NET platform. This programming language is fast and modern and was designed to increase programmer productivity. C# enables programmers to quickly build a wide range of applications for the Microsoft .NET platform.

 

Features:

 

 

Agenda:

 

(Fundamentals)

Basics

  • Overview of C#:
  • Hello world,
  • Assemblies,
  • Common Intermediate Language,
  • Value Types,
  • Reference Types,
  • Common Type System,
  • Common Language Specification,
  • the .NET Virtual Execution System,
  • Common Language Infrastructure, Preprocessing, C# tokens, identifiers, Keywords, declarations, expressions.

 

Namespaces

  • Why namespaces?
  • Namespace syntax,
  • Nested namespaces,
  • Using directives,
  • Type aliases,
  • Namespace aliases,
  • Potential ambiguity,
  • Interoperability,
  • Common mistakes.

 

 

Exceptions

  • Why exceptions?
  • Exception hierarchy,
  • The try-catch statement,
  • Specific catch clauses,
  • Unmanaged exceptions,
  • General catch clauses,
  • Finally blocks,
  • Interoperability,
  • System.Exception,
  • Exception safety, the using statement.

 

Methods

  • Syntax,
  • The Definite Assignment rule,
  • The Invariant Meaning rule,
  • Arguments and parameters,
  • copy parameters,
  • ref parameters,
  • out parameters,
  • overloading methods,
  • CIL overloading,
  • method restrictions,
  • access rules.

 

 

Statements

  • Declarations and expressions, blocks,
  • Name scope,
  • Return statement, throw statement,
  • Bool type, if statement,
  • Wwitch statement, case,
  • While statement, do statement,
  • For statement, foreach statement,
  • Continue statement, break statement.
  • Value Types     

 

 

(Value Types)

Enums and Structs

  • Values vs. references,
  • Declaring enums, the System.Enum class, Using enums, enum conversions,
  • Seclaring structs, creating values,
  • Struct constructors,
  • Chaining constructors,
  • Instance fields, Static fields, Readonly fields,
  • Const fields, local variables, static constructor,
  • Copying, interoperability, common bugs.

 

 

Operators

  • Syntax and restrictions,
  • Assignment, compound assignment, increment and decrement,
  • Operator families, Implicit conversions, explicit conversions,
  • Interoperability and examples

 

Properties and Indexers

  • Why Properties?
  • Fet accessors, set accessors,
  • Static properties, property restrictions, comparing properties to methods, comparing properties to fields,
  • Get accessors, set accessors, indexer restrictions,
  • Comparing indexers to arrays, examples, interoperability, common bugs.
 
 
Numeric Types
  • Integer types, integer overflow, checked and unchecked integer arithmetic,
  • Floating point types, decimal, char, conversions,
  • Typename keyword aliases,
  • Operators, precedence, associativity, evaluation order.
  • Reference Types

 

(Reference Types)

Chars & Strings

  • Char type, the string type,
  • String is immutable,
  • System.String class,
  • System.StringBuilder class,
  • string literals, verbatim string literals, string operators, string conversions, string interning,
  • Assembly metadata, string encoding.

 

Arrays
  • Declaring array variables, creating array instances, initializing arrays,
  • System.Array class,
  • Foreach statement,
  • Variadic methods,
  • Params keyword,
  • Params + object,
  • Ragged arrays, CLS compliance,
  • Common bugs.
  • Classes

 

Classes

  • Declaring classes, creating objects, constructors, chaining constructors,
  • Instance fields, static fields, readonly fields, const fields, static constructors,
  • Copy parameters, ref parameters, out parameters.

 

Boxing

  • Value types compared to reference types, Structs compared to classes, everything derives from object,
  • A problem, the solution - boxing, unboxing, the System.Object class,
  • Do structs really derive from object?

 

(Relationships)

Inheritance

  • Derived classes - base classes,
  • Inheritance syntax, calling base class constructors,
  • Multiple inheritance, virtual methods, override methods,
  • Sealed methods, new methods,
  • Sealed classes, protected access, common bugs.

 

Interfaces

  • Multiple interfaces, implicit interface implementation,
  • Explicit interface implementation, I
  • nterface property, interface indexer,
  • Covariant return types, 
  • Is operator, as operator, typeof operator, System.Type.

 

Abstract Classes

  • Abstract classes, abstract methods,
  • Sealed classes, sealed methods,
  • Complete type/method combination summary.

 

Resources

  • Object birth vs object death,
  • Object.Finalize, destructors/finalizers,
  • non-deterministic finalization,
  • Garbage Collection,
  • the using statement,
  • deterministic Disposal methods, the IDisposable interface.

 

Collections

  • System.Object, the Equals method,
  • Equals in structs, Equals in classes,
  • Hashtable, GetHashCode,
  • ArrayList,
  • IComparable, IComparable contract,
  • Queue, Stack, SortedList,
  • Foreach interface,
  • Foreach Pattern

 

(Systems)

Delegates and Events

  • Typesafe callbacks, declaring a delegate type, creating a delegate instance,
  • Instance method callbacks, static method callbacks,
  • Multicast delegates, declaring delegate fields as events, add and remove accessors,
  • EventHandler, EventsArgs, event publication, event subscription, examples from System.WinForms,
  • Event properties.

 

Attributes

  • What are attributes?
  • Declaring an attribute class,
  • Tagging a code element with an attribute, controlling attribute usage, controlling multiple tags,
  • Positional parameters, named parameters,
  • Assembly metadata, retrieval via reflection.

 

Assemblies

  • What is an assembly?
  • Assemblies vs modules,
  • Manifests, type identity, private assemblies, shared assemblies, Global Assembly Cache,
  • Deploying an assembly, versioning an assembly, versioning policies,
  • Internal access, declaring nested types, nested access, access modifiers, nested access semantics.

 

Interop

  • CLI managed pointers, CLI unmanaged pointers,
  • Unsafe code, verifiability, sizeof, stackalloc, fixed objects, fixed arrays, fixed strings,
  • StructLayoutAttribute, FieldOffsetAttribute, DllImportAttribute, PInvoke, Execution mode thunking, COM interop

 

Remoting

  • App Domains, MarshalByRefObject,
  • Proxying, Assembly dependencies, Interface assemblies, Activation, serialization
  • Contexts, custom proxies, interception.