Synopsis:
This lecture provides an introduction to the C# programming language.
We will cover the basic C# language, some of its unique features, and present several
examples.
Readings and Activities for the Week:
- Text: Advanced C#: Chapter 4, especially delegates, skim .Net Collections: Chapters 7, and quickly read Streams: Chapter 15.
- Look carefully at your second Project assignment - Implement a C# Application: Projects > Project #2
- Based on the structure described in your OCD, begin developing packages for the Project #2 application.
Glossary of Terms
-
Package:
A C# source code file with:- Prologue - comments describing application, platform, and author
- Manual information - comments describing package operations
- Maintenance information - maintenance history
- Class definitions
- Test stub - main guarded by preprocessor directives
- BlockingQueue Example
-
Class:
A C# construct that binds together member functions and data:- Class syntax: class X { ... }
- Method syntax: public void f(T t) { ... }
- Data syntax: private Y y = new Y;
Lecture Content:
- The Syllabus describes topics to be covered, reading material for you to digest as part of each lecture, and due dates for assigned projects.
-
Projects:
-
Sample Project #1
Operational Concept Document for Code Repository OCD -
Sample Project #2
Local Code Repository - Project2SampleHelp - Helper Code for Sample Project #2
- Visual Studio 2012 Help, Package notes
-
Sample Project #1
-
Focus for this Lecture - C# Programming Language
- HelloWorld in C# code, Hello World Code Snap, Console Application Wizard, docx
-
Class relationships,
vsd
Illustrates inheritance, composition, aggregation, and using in class diagram. -
Object relationships,
vsd
Comparison of class and object relationships. -
C# versus C++,
pptx
C# Object Model and Classes, Passing Parameters to Functions - .Net Framework Library, ppt
-
Collected links for C# - Core Technologies
-
Tutorials:
C# Tutorials - MSDN, C# Tutorials - tutorialspoint, C# Tutorials - csharp-station, C# Tutorials - homeandlearn. C# Tutorials - Univ Linz, C# Tutorials - zetcode. .Net Framework Class Library - MSDN
-
Code examples:
-
C# Demos
Introduces classes, class relationships, generics, enumerable types, and extension methods.
All of these are relevant to Project #2. -
C# Syntax Examples
Demonstrates use of arrays, properties, indexers, simple reflection, and disposing. -
.Net containers,
Code Snaps
Use of ArrayList, List<T>, LinkedList, SortedList, HashTable, HashSet<T>, Queue<T>, Stack<T> -
Delegate Structure,
Delegates Demos
Delegates support the publish/subscribe idiom and provide major support for .Net's event model. -
Syntax for using Delegates,
Code Snaps
There are several alternate ways of using delegates. This demo explores them. -
Lambda Capture,
Code Snaps
Lambdas are anonymous callable objects, often bound to delegates. They are used to define thread processing, and often as locally defined functionality that is application specific. -
Navigate Directory Trees
Shows how to walk through a directory tree, using the services of the Directory and Path classes from the Framework Class Library (FCL). -
Navigate with Delegates
Shows how to make the Navigate module reusable by incorporating delegates.
-
C# Demos
-
Components:
- Components Note, Components - Building Blocks for Large Systems,
-
Component:
Interface - an abstract service contract to which the client binds
Implemenation - the service
Factory - standard creator the client uses to avoid binding to implementation - C++ Parser and C# Parser rules are pluggable because they use the component structure.
-
XML:
-
Preparation for Synchronous Discussion:
- Write a brief list of steps required to create a Visual Studio solution, add a project, and build.
- Describe how to setup a Visual Studio Solution so that one package can use the services provided by another package.
-
Lecture Take-away
The most important things we discussed today are:- C# and .Net Framework presentations
- C# demo code.
Passing value and refence types by value and ref, Parameter Passing
These four cases all have different semantics. Delegate Structure, Delegates Demos, Recent additions to C# - delegate shortcuts, lambdas, ...
Delegates support the publish/subscribe idiom and provide major support for .Net's event model.