C#C# C#C# Kit Colbert Student Consultant representing Microsoft

Slides:



Advertisements
Similar presentations
1 Visual C# "Whidbey": Language Enhancements Anders Hejlsberg Distinguished Engineer Microsoft Corporation Anders Hejlsberg Distinguished.
Advertisements

Introduction to C# Anders Hejlsberg Distinguished Engineer Developer Division Microsoft Corporation.
New features in JDK 1.5 Can these new and complex features simplify Java development?
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 12 th -13 th Lecture Pavel Ježek.
Copyright © 2012 Pearson Education, Inc. Chapter 8 Exception Handling.
DEV340 Microsoft Visual C# Under the Covers: An In-Depth Look at C# 2.0 Anders Hejlsberg Distinguished Engineer Microsoft Corporation.
C# Types Tom Roeder CS fa. Administration CMS is up let me know if you can’t see the course Assignments are posted may not be able to do some.
Overview of Visual C# 2005 Henrik Westergaard Hansen
C# Structs, operator overloading & attributes. Structs ~ Structures Structs are similar to classes: they represent data structures with data and functions.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
What’s New in Visual Studio 2005: Security &.NET Framework 2.0 Mike Pelton Developer & Platform Group Microsoft Ltd.
C#/.NET Jacob Lewallen. C# vs.NET.NET is a platform. Many languages compile to.NET: –VB.NET –Python.NET –Managed C++ –C#
C# Language Design Peter Hallam Software Design Engineer C# Compiler Microsoft Corporation.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
C# vs. C++ What's Different & What's New. An example C# public sometype myfn { get; set; } C++ public: sometype myfn { sometype get (); void set (sometype.
BIM313 – Advanced Programming Techniques Object-Oriented Programming 1.
Introduction to C# C# is - elegant, type-safe, object oriented language enabling to build applications that run on the.NET framework - types of applications.
C#C# Introduction CS3260 Dennis A. Fairclough Version 1.0 Introduction CS3260 Dennis A. Fairclough Version 1.0.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 11 th Lecture Pavel Ježek
1162 JDK 5.0 Features Christian Kemper Principal Architect Borland.
Introduction to C # – Part 2 Stephen Turner Software Design Engineer Microsoft UK.
Generics Collections. Why do we need Generics? Another method of software re-use. When we implement an algorithm, we want to re-use it for different types.
DEV300: Advanced C# Eric Gunnerson Program Manager Visual C# Microsoft Corporation.
Advanced C# Eric Gunnerson Program Manager Visual C#.NET Microsoft Corporation.
Introduction to C # – Part 1 Stephen Turner Software Design Engineer Microsoft UK.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Introduction to C#. C# – The Big Ideas The first component oriented language in the C/C++ family Everything.
Modern Software Development Using C#.NET Chapter 5: More Advanced Class Construction.
ILM Proprietary and Confidential -
Visual C# 2005: IDE Enhancements Dan Fernandez C# Product Manager
Hoang Anh Viet Hà Nội University of Technology Chapter 1. Introduction to C# Programming.
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
C# 2.0 and Future Directions Anders Hejlsberg Technical Fellow Microsoft Corporation.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
[ISRAR ALI] Hammad Khan. The namespace keyword is used to declare a scope. Making software components reusable can result in naming collisions (two classes.
Introduction to C# Ali vatankhah. C# – The Big Ideas The first component oriented language in the C/C++ family The first component oriented language in.
Harsh Jegadeesan (CSD) Introduction to C#. Harsh Jegadeesan (CSD) C# – The Big Ideas The first component oriented language in the C/C++ family Everything.
C# C1 CSC 298 Elements of C# code (part 1). C# C2 Style for identifiers  Identifier: class, method, property (defined shortly) or variable names  class,
C Sharp Web & Internet Programming Group Diana, Aren, Jeff, & Adam, Farrin 5/5/20081CS 311.
Advanced C# Types Tom Roeder CS fa. From last time out parameters difference is that the callee is required to assign it before returning not the.
Bill Campbell, UMB Microsoft's.NET C# and The Common Language Runtime.
Introduction to C# 2.0 An Advanced Look Adam Calderon Principal Engineer - Interknowlogy Microsoft MVP – C#
PROGRAMMING IN C#. Collection Classes (C# Programming Guide) The.NET Framework provides specialized classes for data storage and retrieval. These classes.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 11 th Lecture Pavel Ježek
Introduction to C# Adapted from : Anders Hejlsberg, Microsoft CSCE 5013: Hot Topics in Mobile and Pervasive Computing Nilanjan Banerjee University of Arkansas.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
Session 1 C# Basics.
Introduction to C# By: Abir Ghattas Michel Barakat.
Classes Single inheritance Single inheritance Multiple interface implementation Multiple interface implementation Class members Class members  Constants,
Introduction to C# Anders Hejlsberg Distinguished Engineer Developer Division Microsoft Corporation.
Session 02 Module 3: Statements and Operators Module 4: Programming constructs Module 5: Arrays.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
Chapter  Array-like data structures  ArrayList  Queue  Stack  Hashtable  SortedList  Offer programming convenience for specific access.
CSharp Overview Joe Healy Why C# ? First component-oriented language –Builds on COM+ experience –Native support for Namespaces; Versioning.
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
Module 5: Programming with C#. Overview Using Arrays Using Collections Using Interfaces Using Exception Handling Using Delegates and Events.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
C# – The Big Ideas The first component oriented language in the C/C++ family Everything really is an object Next generation robust and durable software.
Chapter 5: Programming with C#
Computing with C# and the .NET Framework
Structs.
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
Visual C# "Whidbey": Language Enhancements
Visual C# 2005: Language Enhancements
DEV321 Visual C# 2005: Language Enhancements
Getting Ready for Visual Studio 2005
Visual C# 2005: Language Enhancements
C# – The Big Ideas The first component oriented language in the C/C++ family The first component oriented language in the C/C++ family Everything really.
Presentation transcript:

C#C# C#C# Kit Colbert Student Consultant representing Microsoft

C# Design goals Design goals Unified type system Unified type system Component-oriented features Component-oriented features Productivity features Productivity features C# futures C# futures Standardization Standardization

C# design goals Dramatically increase productivity Dramatically increase productivity Provide unified and extensible type system Provide unified and extensible type system Support component-oriented programming Support component-oriented programming Enable robust and durable applications Enable robust and durable applications Build foundation for future innovation Build foundation for future innovation

Unified type system Traditional views of primitive types Traditional views of primitive types  C++, Java: They’re “special”  Smalltalk, Lisp: They’re full-blown objects C# unifies with no performance cost C# unifies with no performance cost  Value types, boxing and unboxing  Deep simplicity throughout system Improved extensibility and reusability Improved extensibility and reusability  New primitive types: Decimal, SQL…  Collections, etc., work for all types

Value and reference types Value types Value types  Variables directly contain data  Cannot be null Reference types Reference types  Variables contain references to objects  May be null int i = 123; string s = "Hello world"; 123 i s "Hello world"

Value and reference types Value types Value types  Primitives int i; double x;  Enums enum State { Off, On }  Structs struct Point { int x, y; } Reference types Reference types  Classes class Foo: Bar, IFoo {...}  Interfaces interface IFoo: IBar {...}  Arrays Foo[] a = new Foo[10];  Delegates delegate void Empty();

Classes Inheritance Inheritance  Single base class (System.Object)  Multiple interface implementations Class members Class members  Static and instance members  Nested types Member access Member access  Public, protected, internal, private

Structs Like classes, except Like classes, except  Stored in-line, not heap allocated  Assignment copies data, not reference  Always inherit directly from System.Object Ideal for light weight objects Ideal for light weight objects  Complex, Point, Rectangle, Color  int, float, double, etc., are all structs No heap allocation, less GC pressure No heap allocation, less GC pressure More efficient use of memory More efficient use of memory

Classes and structs class CPoint { int x, y;... } class CPoint { int x, y;... } struct SPoint { int x, y;... } CPoint cp = new CPoint(10, 20); SPoint sp = new SPoint(10, 20); sp cp CPoint

Unified type system Boxing Boxing  Allocates box, copies value into it Unboxing Unboxing  Checks type of box, copies value out int i = 123; object o = i; int j = (int)o; 123 i o 123 System.Int j

Unified type system Several benefits Several benefits  Eliminates “wrapper classes”  Collection classes work with all types Lots of examples in.NET Framework Lots of examples in.NET Framework string s = string.Format( "On {0} your balance was {1}", date, balance); "On {0} your balance was {1}", date, balance); Hashtable t = new Hashtable(); t.Add(0, "zero"); t.Add(1, "one"); t.Add(2, "two");

Component-oriented features What defines a component? What defines a component?  Properties, methods, events, attributes C# has first class support C# has first class support  Not naming patterns, adapters, etc.  Not external files Components are easy to build and consume Components are easy to build and consume

Properties First class language construct First class language construct public class Button: Control { private string text; private string text; public string Text { public string Text { get { get { return text; return text; } set { set { text = value; text = value; Repaint(); Repaint(); } }} Button b = new Button(); b.Text = "OK"; string s = b.Text;

Events First class language construct First class language construct public delegate void EventHandler( object sender, EventArgs e); object sender, EventArgs e); public class Button: Control { public event EventHandler Click; protected void OnClick(EventArgs e) { if (Click != null) Click(this, e); } protected void OnClick(EventArgs e) { if (Click != null) Click(this, e); }} void Initialize() { Button b = new Button(...); Button b = new Button(...); b.Click += new EventHandler(ButtonClick); b.Click += new EventHandler(ButtonClick);} void ButtonClick(object sender, EventArgs e) { MessageBox.Show("You pressed the button"); MessageBox.Show("You pressed the button");}

Attributes How do you associate information with types and members? How do you associate information with types and members?  Category of a property  Transaction context for a method  XML persistence mapping Traditional solutions Traditional solutions  Add keywords or pragmas to language  Use external files (e.g.,.IDL,.DEF) C# solution: Attributes C# solution: Attributes

Attributes public class Button: Control { [Category("Appearance")] [Category("Appearance")] [Description("Color of text in button")] [Description("Color of text in button")] [Browsable(true)] [Browsable(true)] public Color TextColor {...} public Color TextColor {...} protected override void Paint(Graphics g) { protected override void Paint(Graphics g) { TextOut(g.GetHdc(), 10, 10, "Hello"); TextOut(g.GetHdc(), 10, 10, "Hello"); } [DllImport("gdi32", CharSet = CharSet.Auto)] [DllImport("gdi32", CharSet = CharSet.Auto)] static extern bool TextOut(int hDC, static extern bool TextOut(int hDC, int x, int y, string text); int x, int y, string text);} public class CategoryAttribute: System.Attribute { public readonly string Value; public readonly string Value; public CategoryAttribute(string s) { public CategoryAttribute(string s) { Value = s; Value = s; }} Type type = typeof(Button); foreach (Attribute a in type.GetCustomAttributes()) { CategoryAttribute ca = a as CategoryAttribute; CategoryAttribute ca = a as CategoryAttribute; if (ca != null) { if (ca != null) { Console.WriteLine(ca.Value); Console.WriteLine(ca.Value); }}

Attributes Completely extensible Completely extensible  New attributes are created by inheriting from System.Attribute Type-safe Type-safe  Arguments checked at compile-time  Examined using reflection at run-time Extensive use in.NET frameworks Extensive use in.NET frameworks  XML, Web Services, security, serialization, component model, COM and P/Invoke interop, code configuration…

Productivity features parameter arrays parameter arrays ref and out parameters ref and out parameters overflow checking overflow checking foreach statement foreach statement using statement using statement switch on string switch on string

Parameter arrays Can write “printf” style methods Can write “printf” style methods Type-safe, unlike C++ Type-safe, unlike C++ static void printf(string fmt, params object[] args) { foreach (object x in args) { foreach (object x in args) { }} printf("%s %i", s, i); object[] args = new object[2]; args[0] = s; args[1] = i; printf("%s %i", args);

ref and out parameters Use “ref” for in/out parameter passing Use “ref” for in/out parameter passing Use “out” to return multiple values Use “out” to return multiple values Must repeat ref/out at call site Must repeat ref/out at call site static void Swap(ref int a, ref int b) {...} static void Divide(int dividend, int divisor, out int result, out int remainder) {...} out int result, out int remainder) {...} static void Main() { int x = 1, y = 2; int x = 1, y = 2; Swap(ref x, ref y); Swap(ref x, ref y);}

Overflow checking Integer arithmetic operations Integer arithmetic operations  C, C++, Java silently overflow checked vs. unchecked contexts checked vs. unchecked contexts  Default is unchecked, except for constants  Change with “/checked” compiler switch int i = checked(x * y); checked { int i = x * y; int i = x * y;}

foreach statement Iteration of arrays Iteration of arrays Iteration of IEnumerable collections Iteration of IEnumerable collections ArrayList accounts = Bank.GetAccounts(...); foreach (Account a in accounts) { if (a.Balance < 0) Console.WriteLine(a.CustName); if (a.Balance < 0) Console.WriteLine(a.CustName);} public static void Main(string[] args) { foreach (string s in args) Console.WriteLine(s); foreach (string s in args) Console.WriteLine(s);}

using statement static void Copy(string sourceName, string destName) { Stream input = File.OpenRead(sourceName); Stream input = File.OpenRead(sourceName); Stream output = File.Create(destName); Stream output = File.Create(destName); byte[] b = new byte[65536]; byte[] b = new byte[65536]; int n; int n; while ((n = input.Read(b, 0, b.Length)) != 0) { while ((n = input.Read(b, 0, b.Length)) != 0) { output.Write(b, 0, n); output.Write(b, 0, n); } output.Close(); output.Close(); input.Close(); input.Close();} static void Copy(string sourceName, string destName) { Stream input = File.OpenRead(sourceName); Stream input = File.OpenRead(sourceName); try { try { Stream output = File.Create(destName); Stream output = File.Create(destName); try { try { byte[] b = new byte[65536]; byte[] b = new byte[65536]; int n; int n; while ((n = input.Read(b, 0, b.Length)) != 0) { while ((n = input.Read(b, 0, b.Length)) != 0) { output.Write(b, 0, n); output.Write(b, 0, n); } } finally { finally { output.Close(); output.Close(); } } finally { finally { input.Close(); input.Close(); }} static void Copy(string sourceName, string destName) { using (Stream input = File.OpenRead(sourceName)) using (Stream input = File.OpenRead(sourceName)) using (Stream output = File.Create(destName)) { using (Stream output = File.Create(destName)) { byte[] b = new byte[65536]; byte[] b = new byte[65536]; int n; int n; while ((n = input.Read(b, 0, b.Length)) != 0) { while ((n = input.Read(b, 0, b.Length)) != 0) { output.Write(b, 0, n); output.Write(b, 0, n); } }}

using statement Acquire, Execute, Release pattern Acquire, Execute, Release pattern Works with any IDisposable object Works with any IDisposable object  Data access classes, streams, text readers and writers, network classes, etc. using (Resource res = new Resource()) { res.DoWork(); res.DoWork();} Resource res = new Resource(...); try { res.DoWork(); res.DoWork();} finally { if (res != null) ((IDisposable)res).Dispose(); if (res != null) ((IDisposable)res).Dispose();}

Switch on string Color ColorFromFruit(string s) { switch(s.ToLower()) { switch(s.ToLower()) { case "apple": case "apple": return Color.Red; return Color.Red; case "banana": case "banana": return Color.Yellow; return Color.Yellow; case "carrot": case "carrot": return Color.Orange; return Color.Orange; default: default: throw new InvalidArgumentException(); throw new InvalidArgumentException(); }}

C# futures Generics Generics Iterators Iterators Anonymous methods Anonymous methods Partial types Partial types

public class List { private object[] elements; private object[] elements; private int count; private int count; public void Add(object element) { public void Add(object element) { if (count == elements.Length) Resize(count * 2); if (count == elements.Length) Resize(count * 2); elements[count++] = element; elements[count++] = element; } public object this[int index] { public object this[int index] { get { return elements[index]; } get { return elements[index]; } set { elements[index] = value; } set { elements[index] = value; } } public int Count { public int Count { get { return count; } get { return count; } }} Generics public class List public class List { private ItemType[] elements; private ItemType[] elements; private int count; private int count; public void Add(ItemType element) { public void Add(ItemType element) { if (count == elements.Length) Resize(count * 2); if (count == elements.Length) Resize(count * 2); elements[count++] = element; elements[count++] = element; } public ItemType this[int index] { public ItemType this[int index] { get { return elements[index]; } get { return elements[index]; } set { elements[index] = value; } set { elements[index] = value; } } public int Count { public int Count { get { return count; } get { return count; } }} List intList = new List(); intList.Add(1);intList.Add(2);intList.Add("Three"); int i = (int)intList[0]; List intList = new List(); intList.Add(1); // Argument is boxed intList.Add(2); // Argument is boxed intList.Add("Three"); // Should be an error int i = (int)intList[0]; // Cast required List intList = new List (); intList.Add(1); // No boxing intList.Add(2); // No boxing intList.Add("Three"); // Compile-time error int i = intList[0]; // No cast required

Generics Why generics? Why generics?  Compile-time type checking  Performance (no boxing, no downcasts)  Reduced code bloat (typed collections) C# generics vs. C++ templates C# generics vs. C++ templates  C# generics are checked at declaration  C# generics are instantiated at run-time C# generics vs. proposed Java generics C# generics vs. proposed Java generics  C# generics work over entire type system  C# generics preserve types at run-time

Generics Type parameters can be applied to Type parameters can be applied to  Class, struct, interface, and delegate types class Dictionary {...} struct Pair {...} interface IComparer {...} delegate ResType Func (ArgType arg); Dictionary customerLookupTable; Dictionary > orderLookupTable; Dictionary numberSpellings;

Generics Type parameters can be applied to Type parameters can be applied to  Class, struct, interface, and delegate types  Methods class Array { public static T[] Create (int size) { public static T[] Create (int size) { return new T[size]; return new T[size]; } public static void Sort (T[] array) { public static void Sort (T[] array) { }} string[] names = Array.Create (3); names[0] = "Jones"; names[1] = "Anderson"; names[2] = "Williams"; Array.Sort(names);

Generics Constraints Constraints  One base class, multiple interfaces  Specified using “where” clause interface IComparable { int CompareTo(object obj); } class Dictionary class Dictionary { public void Add(K key, V value) { public void Add(K key, V value) { switch (((IComparable)key).CompareTo(x)) { switch (((IComparable)key).CompareTo(x)) {... }... } }} interface IComparable { int CompareTo(object obj); } class Dictionary where K: IComparable { public void Add(K key, V value) { public void Add(K key, V value) { switch (key.CompareTo(x)) { switch (key.CompareTo(x)) {... }... } }} interface IComparable { int CompareTo(T obj); } class Dictionary : IDictionary where K: IComparable, K: IComparable, V: IKeyProvider, V: IKeyProvider, V: IPersistable V: IPersistable {... }

Iterators foreach relies on “enumerator pattern” foreach relies on “enumerator pattern”  GetEnumerator() method returning object with a MoveNext() method and a Current property foreach makes enumerating easy foreach makes enumerating easy  But enumerators are hard to write! foreach (object obj in list) { DoSomething(obj); DoSomething(obj);} Enumerator e = list.GetEnumerator(); while (e.MoveNext()) { object obj = e.Current; object obj = e.Current; DoSomething(obj); DoSomething(obj);}

Iterators public class List { internal object[] elements; internal object[] elements; internal int count; internal int count; public ListEnumerator GetEnumerator() { return new ListEnumerator(this); public ListEnumerator GetEnumerator() { return new ListEnumerator(this); }} public class ListEnumerator { List list; List list; int index; int index; object current; object current; internal ListEnumerator(List list) { internal ListEnumerator(List list) { this.list = list; this.list = list; } public bool MoveNext() { public bool MoveNext() { if (index >= list.count) { if (index >= list.count) { current = null; current = null; return false; return false; } current = list.elements[index++]; current = list.elements[index++]; return true; return true; } public object Current { public object Current { get { return current; } get { return current; } }}

public class List { internal object[] elements; internal object[] elements; internal int count; internal int count; public object foreach() { public object foreach() { for (int i = 0; i < count; i++) yield elements[i]; for (int i = 0; i < count; i++) yield elements[i]; }} Iterators foreach member foreach member  Logical counterpart of foreach statement yield statement yield statement  Produces next value in foreach statement public IEnumerator GetEnumerator() { return new __Enumerator(this); return new __Enumerator(this);} private class __Enumerator: IEnumerator { public bool MoveNext() { public bool MoveNext() { switch (state) { switch (state) { case 0:...; case 0:...; case 1:...; case 1:...; case 2:...; case 2:...; } } public T Current {...} public T Current {...}}

Anonymous methods class MyForm: Form { ListBox listBox; ListBox listBox; TextBox textBox; TextBox textBox; Button addButton; Button addButton; public MyForm() { public MyForm() { listBox = new ListBox(...); listBox = new ListBox(...); textBox = new TextBox(...); textBox = new TextBox(...); addButton = new Button(...); addButton = new Button(...); addButton.Click += new EventHandler(AddClick); addButton.Click += new EventHandler(AddClick); } void AddClick(object sender, EventArgs e) { void AddClick(object sender, EventArgs e) { listBox.Items.Add(textBox.Text); listBox.Items.Add(textBox.Text); }} class MyForm: Form { ListBox listBox; ListBox listBox; TextBox textBox; TextBox textBox; Button addButton; Button addButton; public MyForm() { public MyForm() { listBox = new ListBox(...); listBox = new ListBox(...); textBox = new TextBox(...); textBox = new TextBox(...); addButton = new Button(...); addButton = new Button(...); addButton.Click += new EventHandler(sender, e) { addButton.Click += new EventHandler(sender, e) { listBox.Items.Add(textBox.Text); listBox.Items.Add(textBox.Text); }; }; }}

Anonymous methods delegate bool Filter(object obj); public class ArrayList { public ArrayList Select(Filter matches) { public ArrayList Select(Filter matches) { ArrayList result = new ArrayList(); ArrayList result = new ArrayList(); foreach (object obj in this) { foreach (object obj in this) { if (matches(obj)) result.Add(obj); if (matches(obj)) result.Add(obj); } return result; return result; }} public class Bank { ArrayList accounts; ArrayList accounts; ArrayList GetLargeAccounts(double minBalance) { ArrayList GetLargeAccounts(double minBalance) { return accounts.Select(...); return accounts.Select(...); }} public class Bank { ArrayList accounts; ArrayList accounts; ArrayList GetLargeAccounts(double minBalance) { ArrayList GetLargeAccounts(double minBalance) { return accounts.Select(new Filter( return accounts.Select(new Filter( new MinBalanceSelector(minBalance).Matches)); new MinBalanceSelector(minBalance).Matches)); } class MinBalanceSelector class MinBalanceSelector { double minBalance; double minBalance; public MinBalanceSelector(double minBalance) { public MinBalanceSelector(double minBalance) { this.minBalance = minBalance; this.minBalance = minBalance; } public bool Matches(object obj) { public bool Matches(object obj) { return ((Account)obj).Balance >= minBalance; return ((Account)obj).Balance >= minBalance; } }} public class Bank { ArrayList accounts; ArrayList accounts; ArrayList GetLargeAccounts(double minBalance) { ArrayList GetLargeAccounts(double minBalance) { return accounts.Select( return accounts.Select( new Filter(a) { new Filter(a) { return ((Account)a).Balance >= minBalance; return ((Account)a).Balance >= minBalance; }); }); }}

Partial types public partial class Customer { private int id; private int id; private string name; private string name; private string address; private string address; private List orders; private List orders;} public partial class Customer { public void SubmitOrder(Order order) { public void SubmitOrder(Order order) { orders.Add(order); orders.Add(order); } public bool HasOutstandingOrders() { public bool HasOutstandingOrders() { return orders.Count > 0; return orders.Count > 0; }} public class Customer { private int id; private int id; private string name; private string name; private string address; private string address; private List orders; private List orders; public void SubmitOrder(Order order) { public void SubmitOrder(Order order) { orders.Add(order); orders.Add(order); } public bool HasOutstandingOrders() { public bool HasOutstandingOrders() { return orders.Count > 0; return orders.Count > 0; }}

C# and CLI standardization Work begun in September 2000 Work begun in September 2000  Intel, HP, IBM, Fujitsu, Plum Hall, and others ECMA standards ratified in December 2001 ECMA standards ratified in December 2001 Fast track to ISO Fast track to ISO Several CLI and C# implementations Several CLI and C# implementations .NET Framework and Visual Studio.NET  “SSCLI” – Shared source on XP, FreeBSD, OS X  “Mono” – Open source on Linux Standardization of new features ongoing Standardization of new features ongoing

Q & A.NET Framework SDK (includes C# compiler).NET Framework SDK (includes C# compiler)  Microsoft Visual C#.NET Microsoft Visual C#.NET  ECMA C# Standard ECMA C# Standard  Microsoft Research Generics prototype Microsoft Research Generics prototype  Whitepaper on future C# language features Whitepaper on future C# language features  NUnit unit-testing framework for.NET NUnit unit-testing framework for.NET 