Netdesk 2124 12/12/2005 – 12/16/2005

 

Day 1 2005.12.12

 

Rick White MCSD, MCDBA, MCT

Rick.White@netdesk.com

 

 

 

 

 

 

Foreach (int number in numbers){

Console.WriteLine(numer);

}

 

 

 

Day 2 2005.12.13

 

 

static void m(int i)

{

 

}

 

 

static void m(ref int i)

{

 

}

 

 

Calling…

Blabla(1,2,3);

 

In the called method

Static void blabla(params int[p])

{

Console.WriteLine(args[0]);

Console.WriteLine(args[1]);

Console.WriteLine(args[2]);

}

 

or…

 

Foreach (int i in p) {}

 

 

 

 

 

long[ ] bla = new long {0,1,2,3}

long[4] bla = new long {0,1,2,3}

 

…both are OK

 

§       You can assign length to arrays at run time

§       Copied arrays

·       Shallow copy (new array = old array) puts copies of the data contained in the old array in the new array, either values or references, depending on what was in the array

 

o      Classes

§       Data structure that contains both data and functions

§       All variables in a struct end up in stack, classes end up in heap

§       Encapsulation is keeping certain things in the class hidden from external code

§       this” allows you to find the object in which this code is currently running doesn’t work in static methods

 

 

Day 3 2005.12.14

 

 

 

IWhateverInterface a = new MyClass();

 

 

WhateverType a = (WhateverType)b;

 

if this works, a and b both point to the same obj on the managed heap; that obj on the managed heap may be of WhateverType or a child of WhateverType

 

 

 

System.Type t = obj.GetType();

Console.WriteLine(t.Name);

 

Or

 

Console.WriteLine(obj.GetType().Name);

 

 

public Child(type[s] ChildParam[s]) :Base(type[s] ParentParam[s])

{

                   …

}

 

…in the child constructor, and the parent’s non default constructore will get called

 

 

 

 

Day 4 2005.12.15

 

 

interface IToken

{

int LineNumber();

string name();

}

 

 

IXyz x = new Abc();

 

…this instantiates an obj x of type Abc, in which only the IXyz members are available

 

 

 

 

 

 

Day 5 2005.12.16

 

 

new d1(B.m);

d+=d1;

new d2(F.m);

d+=d2;

 

 

 

 

 

(Diagram to complement code on page 46)

 

 

 

 

private event D E;

 

…this way, when the event E gets thrown, the delegate gets invoked, which invokes each individual method which is referred to by the multicast delegate

 

 

class A

{

public long this[int i]{}

}

 

…note that the data type doesn’t have to be long.