Download presentation
Presentation is loading. Please wait.
1
1.NET and C# Peter Groenewegen Vrije Universiteit pgroene@few.vu.nl
2
2.NET and C# Part 1.NET
3
3 The.NET Evolution User Experience XML Store Building Blocks PC and other devices Universal Canvas.NET Platform MS Services Partner Services APIs User Interface File System PC Compound Document Windows Platform MS Apps Partner Apps As big a transition as from DOS to Windows
4
4.NET Simpler programming model Web Services Many devices
5
5 Many Devices IntelWin32 Winforms universal runtime
6
6 Intermediate Language All languages are compiled to an intermediate language
7
7 Intermediate Language Computer Language IntelPPC6502 runtime libraries runtime libraries runtime libraries
8
8 Intermediate Language Computer Language IntelPPC6502 Intermediate Language runtim e libraries
9
9 Intermediate Language C# IntelPPC6502 MSIL runtim e libraries PerlPascal runtim e libraries runtim e libraries runtim e libraries
10
10 Common Language Runtime
11
11.NET Simpler programming model Web Services Many devices
12
12 Web Services DCOMASP ASP+, Webforms SOAP Biztalk
13
13 Web Services … ??????? ASP
14
14 Web Services Webservice
15
15 Web Services DCO M CORBA CORBA implementations are not compatible DCOM location transparency does not hold on the web CORBA and DCOM are not compatible
16
16 Web Services Functionality for development and management of.NET services: Application Center 2000: Extreme reliability and scalability Internet Security & Acceleration Server: Firewall and proxy server Commerce Server: analyzing site usage BizTalk Server 2000: Business process orchestration & Business-to-business document interchange using XML SQL Server 2000: Easy-to-use database systems with native Extensible Markup Language (XML) support Host Integration Server 2000: Integration with host systems and their data Mobile Information 2001 Server: Integration with mobile devices
17
17.NET Simpler programming model Web Services Many devices
18
18 Simpler programming model Component Based Java C# Object Oriented C++ PythonPerl Cobol Haskell VB
19
19 Simpler programming model Cross-language implementation inheritance Cross-language exception handling Cross-language debugging ASP+ pages in any language Client-side scripts in any language Languages include Perl, Python, COBOL, Pascal, Oberon,... Haskell, Mercury, Eiffel, … C, C++,C#, …
20
20 Versioning X.dll Version 1949 Implementation relied on “secret” API removed in new version X.dll Version 2001 Office 2000 SP1 Leisure suit Larry Salary The programmer was aware of a bug and thought he was smart to use the feature
21
21 What else... Free standards XML Performance Backwards compatibility Lots of code ready to use ...
22
22 The.NET evolution User Experience XML Store Building Blocks PC and other devices Universal Canvas.NET Platform MS Services Partner Services APIs User Interface File System PC Compound Document Windows Platform MS Apps Partner Apps DOS Windows = Windows .NET Windows .NET
23
23.NET and C# Part 2 C#
24
24 C# Not MS alternative for Java Language for programming.NET framework Which is MS alternative for JVM
25
25 Hello World using System; class Hello { static void Main() { Console.WriteLine("Hello world"); } csc HelloWorld.cs ildasm HelloWorld.exe DEMO
26
26 Namespaces Types, namespaces Types, namespaces Type declarations Classes, interfaces, structs, enums, delegates Classes, interfaces, structs, enums, delegates Members Fields,methods, constants, properties, events, indexers, operators, constructors, destructors Fields,methods, constants, properties, events, indexers, operators, constructors, destructors package inner classes Java Beans void finalize () C# Program Structure
27
27 Boxing/Unboxing Boxing Allocates box, copies value into it Allocates box, copies value into it Unboxing Checks type of box, copies value out Checks type of box, copies value out int i = 123; object o = i; int j = (int)o; 123 i o System.Int32 123 j
28
28 Value Types Struct type struct Point { int x, y; } Simple type int i; Enums type enum State { Off, On } Everything is really an object
29
29 Refrence types Interface type Delegate type Class type Array type
30
30 Unsafe code Unsafe code Low-level code without leaving the box Low-level code without leaving the box Enables unsafe casts, pointer arithmetic Enables unsafe casts, pointer arithmetic Declarative pinning fixed statement fixed statement Basically “inline C”
31
31 Unsafe code 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); }
32
32 Properties Properties are “smart fields” Natural syntax, accessors, inlining Natural syntax, accessors, inlining class Borrel { private int start; public int Start { get { return start; } set { if (value 2400) Console.WriteLine(“Invalided time”); else start = value; } } } class Demo { public static Main () { Borrel b = new Borrel(); b.Start = 1745; int start = b.Start; } }
33
33 Indexers Indexers are “smart arrays” Can be overloaded Can be overloaded class Borrel { private Dictionary participants; public Borrel() { participants = new Dictionary(); } public bool this[String name] { get { return (participants.Contains(name) && (bool)participants[name]); } set { participants.Add(name,value); } } } class Demo { public static void Main () { Borrel b = new Borrel (); b[“Peter”] = true; Console.WriteLine(b[“Bill”]); } }
34
34 Dogs Demo Thanks Roger and Eric Sessions! using System; namespace VirtualDog { public class Dog { public virtual void RollOver () { Console.WriteLine("Scratch my tummy."); Bark(); } public virtual void Bark () { Console.WriteLine("WOOF WOOF (Dog)"); } } } Imports System Namespace VirtualDog Public Class Mopje : Inherits Dog Public overrides Sub Bark () Console.WriteLine("WOEF WOEF (Mopje)") End Sub End Class End Namespace import VirtualDog; var d = new Dog(); var m = new Mopje(); d.RollOver(); m.RollOver();
35
35 What more? Versioning XML comments (Demo?) Conditional compilation ...
36
36 References and more info C# session by Tony Goodhew, TechEd 2000 .NET session Eric Meijer C# session Eric Meijer http://www.cs.vu.nl/~pgroene/Vakken/ Oop/oop.html
37
37 Questions?
38
38 Where do you what to go today?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.