Background and general information on C#

Lesson 1

.NET Framework Overview

The common type system (CTS) provides

.NET and Languages

.NET App Structure

Compilation and Execution

Lesson 2

.NET Base Class Library



Namesapce Description
System Root. Contains low-level and primitive types
System.Collections Types for arrays, lists, queues and stacks. Abstract classes to implement own collections
System.ComponentModel   Component creation and containment - attributes, type converters, license providers
System.Data Database access and manipulations
System.Data.Common Classes shared by .NET managed data providers
System.Data.OleDb Managed provider for OLE DB
System.Data.SqlClient Managed provider for SQL server
System.Drawing GDI+ functionality
System.IO File system IO
System.Math Roots, trig, etc.
System.Reflection Obtain info on and dynamically create types at run-time
System.Security Permissions, cryptography and code access
System.Threading Supports multi-threaded apps
System.Windows.Forms Supports standard windows apps (forms and consoles)


Table 2 Representative .NET Namespaces

Reference and Value Types

Using .NET Framework in App

int myInteger;
myInteger = 42;
System.Windows.Forms.Form myForm;
myForm = new System.Windows.Forms.Form
Widget mywidget;

myWidget = new Widget("doodah");

Using Statement

using myAlias = MyNamespace.Widget

myNamespace.Widget widget = new myNamespace.Widget

myAlias anotherWidget = new myAlias

External Libraries

  1. From Solution Explorer right click projects References node

  2. Choose Add Reference. Add Reference dialog box appears

  3. Choose tab for library to reference. .NET libraries are on .NET tab. COM libraries on COM tab. Local Visual Studio projects on Projects tab

  4. Load library and double click to add to Selected components box. Click OK to confirm reference

Lesson 3

Classes and Structures

public class Widget 
// Class implementation goes here

public int Spin; // Member field

private class Thing
// Nested class code

public struct Vector
// Structure implementation goes here

public int Add( int first, int second)
// Method implementation
return first + second;

Lesson 4



public int Demo2( int p1, ref int p2) 

public void aWord( out sring Word )
Word = "Mambo";

Constructors and Destructors

Lesson 5

Scope and Access Levels

Access Modifier Affect
public Accessed from anywhere
private Accessed from members within type defining it
internal Accessed from within assembly
protected Accessed from members within type or types inheriting from the owning type
protected internal   Accessed from within assembly or from types inheriting from the owning type


Table 2 Access Modifiers

Static Members

public class Demo 
public static int MyField;
Demo Object1 = new Demo();

Object1.MyField = 15; // Incorrect

Demo.MyField = 15; // Correct

Lesson 6

Garbage Collection

Circular References