1 / 22

Microsoft's .NET

Microsoft's .NET. C# and The Common Language Runtime . Correspondence. Correspondence (cont). C# a language for programmers. From C and C++ Managed Data (garbage collection) Larger than Java (80 vs 50 keywords) Preprocessing directives, #ifdef etc. Operator overloading

dyan
Download Presentation

Microsoft's .NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microsoft's .NET C# and The Common Language Runtime Bill Campbell, UMB

  2. Correspondence Bill Campbell, UMB

  3. Correspondence (cont) Bill Campbell, UMB

  4. C# a language for programmers • From C and C++ • Managed Data (garbage collection) • Larger than Java • (80 vs 50 keywords) • Preprocessing directives, #ifdef etc. • Operator overloading • Syntactic sugar (convenience) Bill Campbell, UMB

  5. Type Value Type Ref Type Scalar Enumeration Class Interface Structure Delegate Everybody's an Object (stack allocated) (heap allocated) Bill Campbell, UMB

  6. Choice in Scalars sbyte float char byte double bool short decimal ushort int uint long ulong Bill Campbell, UMB

  7. Scalars are structs int is really syntax for Int32 struct Int32 {... } so, e.g. 56.ToString() Bill Campbell, UMB

  8. 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

  9. foreach foreach (int elem in intArray) { … } foreach (BankAccount acct in accounts) { … } Bill Campbell, UMB

  10. 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

  11. Behave like getters and setters public double DegreesCelsius { get { return degreesCelsius; } set { degreesCelsius = value; } } Bill Campbell, UMB

  12. DegreesFahrenheit Property public double DegreesFahrenheit { get { return 9.0/5.0*DegreesCelsius + 32.0; } set { DegreesCelsius = 5.0/9.0*(value-32.0); } } Bill Campbell, UMB

  13. Indexers public class BitSet { ulong word; public bool this[int position] { get { if (position < 0 || position > 63) throw new IndexOutOfRangeException(); else return word & (1 << position) != 0; } ... } Bill Campbell, UMB

  14. Properties and Indexers Ubiquitous button.Size "cat".length => 3 "cat"[1] => 'a' hashtable["key"] = "value"; ... hashtable["key"] => "value" Bill Campbell, UMB

  15. Boxing and Unboxing Like Java, Collections of (Reference) Objects hashtable["one"] = (object) 1; // 1 boxed int one = (int) hashtable["one"]; // unboxed Bill Campbell, UMB

  16. 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) { <do whatever you want for a pressed button> } Bill Campbell, UMB

  17. 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, ... Your program can act Encrypted = 0x4000 upon them at run time } Bill Campbell, UMB

  18. Common Language Runtime (CLR) • Visual Basic • C++ • JScript  CLR (JIT)  native code • C# • (others) CLR a model Bill Campbell, UMB

  19. Common Type System Your language can talk to all the others so long as it supports: bool short ulong char int float long double byte Bill Campbell, UMB

  20. CLR Entities • 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) • One assembly can be physically captured by several (.exe or .dll) files • Support versioning • Can operate under one of several publishing policies (eg bug fixes vs. new versions) • Namespaces are purely logical Bill Campbell, UMB

  21. CLR Implementation • CLR has a real assembly language assembly P -ildasm -ilasm P  • CLR is a beautiful target for compilers • Implemented using a "just in time" compiler • Generational garbage collector Bill Campbell, UMB

  22. How to learn about this stuff • Internet • Good books (Microsoft Press) • 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.) • Take one of my summer courses: CS650 or CS697a (both limited in size) Bill Campbell, UMB

More Related