Presentation is loading. Please wait.

Presentation is loading. Please wait.

The 100% Inspiration Tour.

Similar presentations


Presentation on theme: "The 100% Inspiration Tour."— Presentation transcript:

1 The 100% Inspiration Tour

2 Exploring the .NET Framework with C#
David Chalmers Academic Team, Microsoft UK

3 Topics Exploring the .NET Framework SDK
What actually is .NET? Understanding key Framework concepts Delving into the Common Language Runtime Introducing the C# programming language

4 What is .NET? Software for connecting people, information, systems and devices? Runtime for executing code Tools to help develop applications Server products to manage applications Value-added services Managed environment for developing and executing components

5 .NET Framework SDK A platform for building Standards based
XML Web services Windows Applications Web Applications Mobile Device Applications Standards based Enhances developer productivity Simplifies application development Makes delivery of complex applications possible

6 Creating Our First .NET Application

7 A Modest Application! Module Module1 Sub Main() 10:
Console.WriteLine(“I rock”) 20: GoTo 10 End Sub End Module

8 Introducing C# Less typing! Object Orientation
Better control structures Combines best features of C/C++ Java Visual Basic

9 Languages with {}; using System; public class HelloWorld {
static void Main(string[] args) Console.WriteLine(s); }

10 A Improved ‘Hello, World’
using System; public class HelloWorld { static void Main(string[] args) string[] strArray = {“I rock”, “You rock”, “We all rock”}; foreach(string s in strArray) Console.WriteLine(s); }

11 C# Program Structure using System; namespace System.Collections {
public class Stack Entry top; public void Push(object data) { top = new Entry(top, data); } public object Pop() { if (top == null) throw new InvalidOperationException(); object result = top.data; top = top.next; return result;

12 Properties Properties are “smart fields”
Natural syntax, accessors, inlining public class Button: Control { private string caption; public string Caption { get { return caption; } set { caption = value; Repaint(); Button b = new Button(); b.Caption = "OK"; String s = b.Caption;

13 Attributes public class OrderProcessor { [WebMethod]
public void SubmitOrder(PurchaseOrder order) {...} } [XmlRoot("Order", Namespace="urn:acme.b2b-schema.v1")] public class PurchaseOrder [XmlElement("shipTo")] public Address ShipTo; [XmlElement("billTo")] public Address BillTo; [XmlElement("comment")] public string Comment; [XmlElement("items")] public Item[] Items; [XmlAttribute("date")] public DateTime OrderDate; public class Address {...} public class Item {...}

14 Indexers Indexers are “smart arrays” Can be overloaded
public class ListBox: Control { private string[] items; public string this[int index] { get { return items[index]; } set { items[index] = value; Repaint(); ListBox listBox = new ListBox(); listBox[0] = "hello"; Console.WriteLine(listBox[0]);

15 foreach Statement Iteration of arrays
Iteration of user-defined collections public static void Main(string[] args) { foreach (string s in args) Console.WriteLine(s); } foreach (Customer c in customers.OrderBy("name")) { if (c.Orders.Count != 0) { ... }

16 C# – The Big Ideas Everything is an Object
Traditional views C++, Java: Primitive types are ‘magic’ and do not interoperate with objects Smalltalk, Lisp: Primitive types are objects, but at great performance cost C# unifies with no performance cost Deep simplicity throughout system Improved extensibility and reusability New primitive types: Decimal, SQL… Collections, etc., work for all types

17 C# – The Big Ideas Building Robust Code
Garbage collection No memory leaks and stray pointers Exceptions Error handling is not an afterthought Type-safety No uninitialised variables, unsafe casts Versioning Pervasive versioning considerations in all aspects of language design

18 Advanced Coding Capabilities
class FileStream: Stream { int handle; public unsafe int Read(byte[] buffer, int index, int count) { int n = 0; fixed (byte* p = buffer) { ReadFile(handle, p + index, count, &n, null); } return n; [dllimport("kernel32", SetLastError=true)] static extern unsafe bool ReadFile(int hFile, void* lpBuffer, int nBytesToRead, int* nBytesRead, Overlapped* lpOverlapped);

19 Objects and Types Need a way of grouping code with the data it operates on Classes Primitive types Operations on those types Ensuring interoperability Common Type System The Common Language Specification (CLS)

20 Libraries and the CLS Classes for objects that are generally useful or support specific application types are built into libraries Most of the base-class libraries are CLS compliant Can be called by any component you create in a CLS-compliant programming language

21 Don’t Start from Scratch!
Lots of good content out there to learn from Quick Start Tutorials samples.gotdotnet.com/quickstart ASP.NET Starter Kits Sample Applications IBuySpy Pet Store Many more …

22 Delving into Source Code

23 What’s Under the Hood? Assemblies Execution Managed Execution IL
Metadata Execution Class Loader Security Verification Managed Execution Just In Time Compilation Garbage Collection

24 Common Language Specification Common Language Runtime
The .NET Framework VB C++ C# JScript Visual Studio.NET Common Language Specification ASP.NET Windows Forms Data and XML Base Class Library Web Matrix Common Language Runtime Windows COM+ Services

25 Common Language Runtime
Base Class Library Support Thread Support COM Marshaler Type Checker Exception Manager Security Engine Debug Engine IL to Native Compilers Code Manager Garbage Collector Class Loader

26 Compilation and Execution Model
Source Code Language Compiler Assembly Code (IL) Metadata Execution JIT Compiler Native Code At installation or the first time each method is called

27 Summary Flexible platform for sharing code and data across
languages Processes Machines Sites or domains Execution Environment Powerful language support Great tools and utilities for developers

28 Further Resources .NET Framework SDK Further Reading
msdn.microsoft.com/netframework msdn.microsoft.com/vstudio Further Reading Applied .NET Framework Programming. Richter, J. (2002); Microsoft Press Inspiration Tour Site

29 © 2003 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.


Download ppt "The 100% Inspiration Tour."

Similar presentations


Ads by Google