Bill Campbell, UMB Microsoft's.NET C# and The Common Language Runtime
Bill Campbell, UMB Correspondence Java (J2EE).Net Family of Standards Family of Products Cross platform Windows Java C# (VB, C++, Jscript) & others & others JSPASP+
Bill Campbell, UMB Correspondence (cont) Java (J2EE).Net JDBC.ADO EJBDCOM+ IIOP, SOAP (xml) Remoting, SOAP Several Vendors One vendor
Bill Campbell, UMB C# a language for programmers From C and C++ From C and C++ Managed Data (garbage collection) Managed Data (garbage collection) Larger than Java Larger than Java (80 vs 50 keywords)(80 vs 50 keywords) Preprocessing directives, #ifdef etc.Preprocessing directives, #ifdef etc. Operator overloadingOperator overloading Syntactic sugar (convenience)Syntactic sugar (convenience)
Bill Campbell, UMB Everybody's an Object Type Value Type Ref Type Scalar Enumeration Class Interface Structure (stack allocated) (heap allocated) Delegate
Bill Campbell, UMB Choice in Scalars sbytefloatchar bytedoublebool shortdecimal ushortintuintlongulong
Bill Campbell, UMB Scalars are structs int is really syntax for Int32 struct Int32 {...} so, e.g. 56.ToString()
Bill Campbell, UMB keywords abstract as base bool break byte case catch char checked class const continue decimal default delegate do double else enum event explicit extern false final fixed float for foreach goto if implicit in int interface internal is lock long namespace new null object operator out override params private protected public readonly ref return sbyte sealed short sizeof stackalloc static string struct switch this throw true try typeof uint ulong unchecked void volatile while
Bill Campbell, UMB foreach foreach (int elem in intArray) {…} foreach (BankAccount acct in accounts) {…}
Bill Campbell, UMB Properties mimic field syntax Temperature t = New Temperature(...);... double c = t.DegreesCelsius;... t.DegreesCelsius = 0.0; double f = t.DegreesFarenheit; // 32.0
Bill Campbell, UMB Behave like getters and setters public double DegreesCelsius {get{ return degreesCelsius; }set{ degreesCelsius = value; }}
Bill Campbell, UMB DegreesFahrenheit Property public double DegreesFahrenheit {get{ return 9.0/5.0*DegreesCelsius ; }set{ DegreesCelsius = 5.0/9.0*(value-32.0); }}
Bill Campbell, UMB Indexers public class BitSet { ulong word; ulong word; public bool this[int position] public bool this[int position] {get{ if (position 63) if (position 63) throw new IndexOutOfRangeException(); else else return word & (1 << position) != 0; }...}
Bill Campbell, UMB Properties and Indexers Ubiquitous button.Size "cat".length => 3 "cat"[1] => 'a' hashtable["key"] = "value";... hashtable["key"] => "value"
Bill Campbell, UMB Boxing and Unboxing Like Java, Collections of (Reference) Objects hashtable["one"] = (object) 1; // 1 boxed hashtable["one"] = (object) 1; // 1 boxed int one = (int) hashtable["one"]; // unboxed int one = (int) hashtable["one"]; // unboxed
Bill Campbell, UMB Delegates and Events Type safe callbacks Button button = new Button("Press Me"); button.Click += new System.EventHandler(button_Click);... private void button_Click(object sender, System.EventArgs e) { }
Bill Campbell, UMB Attributes For marking up your program [Serializable] class BankAccount {... } [Flags, Serializable]You can define your own public enum FileAttributes {They can have arguments ReadOnly = 0x0001, ReadOnly = 0x0001,...Your program can act...Your program can act Encrypted = 0x4000 upon them at run time Encrypted = 0x4000 upon them at run time}
Bill Campbell, UMB Common Language Runtime (CLR) Visual Basic Visual Basic C++ C++ JScript CLR (JIT) native code JScript CLR (JIT) native code C# C# (others) CLR a model (others) CLR a model
Bill Campbell, UMB Common Type System Your language can talk to all the others so long as it supports: boolshort ulong charint floatlong doublebyte
Bill Campbell, UMB CLR Entities Assemblies are logical collections of program parts (classes, interfaces, etc.) Assemblies are logical collections of program parts (classes, interfaces, etc.) Contain ALL the metadata required for an application (so it doesn't have to go in registries)Contain ALL the metadata required for an application (so it doesn't have to go in registries) One assembly can be physically captured by several (.exe or.dll) filesOne assembly can be physically captured by several (.exe or.dll) files Support versioningSupport versioning Can operate under one of several publishing policies (eg bug fixes vs. new versions)Can operate under one of several publishing policies (eg bug fixes vs. new versions) Namespaces are purely logical Namespaces are purely logical
Bill Campbell, UMB CLR Implementation CLR has a real assembly language CLR has a real assembly language assembly P -ildasm -ilasm P assembly P -ildasm -ilasm P CLR is a beautiful target for compilers CLR is a beautiful target for compilers Implemented using a "just in time" compiler Implemented using a "just in time" compiler Generational garbage collector Generational garbage collector
Bill Campbell, UMB How to learn about this stuff Internet Internet Good books (Microsoft Press) Good books (Microsoft Press) Download the MS Framework SDK Download the MS Framework SDK Borrow Visual Studio.net under the msdnaa program here at umb (You must be a student and adhere to the licensing agreement.) Borrow Visual Studio.net under the msdnaa program here at umb (You must be a student and adhere to the licensing agreement.) Take one of my summer courses: CS650 or CS697a (both limited in size) Take one of my summer courses: CS650 or CS697a (both limited in size)