Whidbey Tutorial
Whidbey Tutorial
0 and Visual
Studio 2005
SigWin 2004
Outline
Language enhancements in C#
– Generics
– Partial types
– Anonymous methods
– Nullable types
IDE features
– Intellisense
– Refractoring
– Code snippets
– Other awesome stuff!
Generics
Motivation
Generics
One method:
public int AddSeconds(ArrayList myList) {
int total=0;
DateTime myDate;
foreach (object myObj in myList) {
myDate=(DateTime) myObj;
total+=myDate.Second;
}
return total;
}
Generics
System.Collections.Generic:
Review of delegates
Anonymous delegate=delegate
without a function name, just code
Anonymous method
example:
button1.Click += delegate { MessageBox.Show("Click"); };
Alternative:
button1.Click+=new EventHandler(myButton1_Click);
Demo!