net and c#
DESCRIPTION
.NET and C#. Peter Groenewegen Vrije Universiteit [email protected]. . NET and C#. .NET. Part 1. Partner Apps. Partner Services. MS Apps. MS Services. User Interface. User Experience. Compound Document. Universal Canvas. File System. XML Store. APIs. Building Blocks. - PowerPoint PPT PresentationTRANSCRIPT
![Page 2: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/2.jpg)
2
..NET and C#NET and C#
Part 1Part 1
.NET.NET
![Page 3: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/3.jpg)
3
The .NET EvolutionThe .NET Evolution
User ExperienceUser Experience
XML StoreXML Store
Building BlocksBuilding Blocks
PC and other devicesPC and other devices
Universal CanvasUniversal Canvas
.NET Platform.NET Platform
MS MS ServicesServices
Partner Partner ServicesServices
APIsAPIs
User InterfaceUser Interface
File SystemFile System
PCPC
Compound DocumentCompound Document
Windows PlatformWindows Platform
MS MS AppsApps
Partner Partner AppsApps
As big a transition as from As big a transition as from DOS to WindowsDOS to Windows
![Page 4: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/4.jpg)
4
.NET.NET
Simpler programming
model
WebServices
Many devices
![Page 5: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/5.jpg)
5
Many DevicesMany Devices
Intel Win32
Winformsuniversal runtime
![Page 6: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/6.jpg)
6
Intermediate LanguageIntermediate Language
All languages are compiled to an All languages are compiled to an intermediate languageintermediate language
![Page 7: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/7.jpg)
7
Intermediate LanguageIntermediate Language
Computer Language
Intel PPC 6502runtime
librariesruntime
librariesruntime
libraries
![Page 8: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/8.jpg)
8
Intermediate LanguageIntermediate Language
Computer Language
Intel PPC 6502
Intermediate Language runtime
libraries
![Page 9: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/9.jpg)
9
Intermediate LanguageIntermediate Language
C#
Intel PPC 6502
MSIL runtime
libraries
Perl Pascal
runtimelibraries
runtimelibraries
runtimelibraries
![Page 10: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/10.jpg)
10
Common Language RuntimeCommon Language Runtime
![Page 11: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/11.jpg)
11
.NET.NET
Simpler programming
model
WebServices
Many devices
![Page 12: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/12.jpg)
12
Web ServicesWeb Services
DCOM ASP
ASP+, Webforms
SOAP
Biztalk
![Page 13: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/13.jpg)
13
Web ServicesWeb Services
<html>…</html>
???????
ASP
![Page 14: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/14.jpg)
14
Web ServicesWeb Services
Webservice
Webservice
Webservice
Webservice
![Page 15: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/15.jpg)
15
Web ServicesWeb Services
DCOM
DCOM
DCOM
CORBA
CORBA
CORBA
CORBA
CORBACORBA
implementations are not
compatible
DCOM location transparency does not hold
on the web
CORBA and DCOM are not
compatible
![Page 16: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/16.jpg)
16
Web ServicesWeb Services
Functionality for development and management of .NET services:Functionality for development and management of .NET services: Application Center 2000: Extreme reliability and scalabilityApplication Center 2000: Extreme reliability and scalability Internet Security & Acceleration Server: Firewall and proxy Internet Security & Acceleration Server: Firewall and proxy
serverserver Commerce Server: analyzing site usage Commerce Server: analyzing site usage BizTalk Server 2000: Business process orchestration & BizTalk Server 2000: Business process orchestration &
Business-to-business document interchange using XML Business-to-business document interchange using XML SQL Server 2000: Easy-to-use database systems with native SQL Server 2000: Easy-to-use database systems with native
Extensible Markup Language (XML) support Extensible Markup Language (XML) support Host Integration Server 2000: Integration with host systems Host Integration Server 2000: Integration with host systems
and their dataand their data Mobile Information 2001 Server: Integration with mobile Mobile Information 2001 Server: Integration with mobile
devices devices
![Page 17: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/17.jpg)
17
.NET.NET
Simpler programming
model
WebServices
Many devices
![Page 18: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/18.jpg)
18
Simpler programming modelSimpler programming model
ComponentBased Java
C#
Object Oriented
C++
Python Perl
Cobol
Haskell
VB
![Page 19: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/19.jpg)
19
Simpler programming modelSimpler 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#, …
![Page 20: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/20.jpg)
20
VersioningVersioning
X.dllVersion 1949
Implementation relied on “secret” API
removed in new version
X.dllVersion 2001
Office 2000SP1
Leisure suit Larry
Salary
The programmer was aware of a bug
and thought he was smart to use
the feature
![Page 21: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/21.jpg)
21
What else...What else...
Free standardsFree standards XMLXML PerformancePerformance Backwards compatibilityBackwards compatibility Lots of code ready to useLots of code ready to use ......
![Page 22: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/22.jpg)
22
The .NET evolutionThe .NET evolution
User ExperienceUser Experience
XML StoreXML Store
Building BlocksBuilding Blocks
PC and other devicesPC and other devices
Universal CanvasUniversal Canvas
.NET Platform.NET Platform
MS MS ServicesServices
Partner Partner ServicesServices
APIsAPIs
User InterfaceUser Interface
File SystemFile System
PCPC
Compound DocumentCompound Document
Windows PlatformWindows Platform
MS MS AppsApps
Partner Partner AppsApps
DOS DOS Windows = Windows = Windows Windows .NET .NET
![Page 23: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/23.jpg)
23
.NET and C#.NET and C#
Part 2Part 2
C#C#
![Page 24: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/24.jpg)
24
C#C#
Not MS alternative for Java
Language for programming.NET framework
Which is MS alternative forJVM
![Page 25: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/25.jpg)
25
Hello WorldHello World
using System;class Hello{ static void Main() { Console.WriteLine("Hello world"); }}
csc HelloWorld.cs
ildasm HelloWorld.exe
DEMO
![Page 26: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/26.jpg)
26
NamespacesNamespaces TypesTypes, namespaces, namespaces
Type declarationsType declarations Classes, interfaces, structs, enums, Classes, interfaces, structs, enums,
delegatesdelegates
MembersMembers Fields,methods, constants, Fields,methods, constants, propertiesproperties, ,
events, events, indexersindexers, operators, , operators, constructors, destructorsconstructors, destructors
package
inner classes
Java Beansvoid finalize
()
C# Program StructureC# Program Structure
![Page 27: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/27.jpg)
27
Boxing/UnboxingBoxing/Unboxing
BoxingBoxing Allocates box, copies value into itAllocates box, copies value into it
UnboxingUnboxing Checks type of box, copies value outChecks type of box, copies value out
int i = 123;object o = i;int j = (int)o;
123i
o
123
System.Int32
123j
![Page 28: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/28.jpg)
28
Value TypesValue Types
Struct type struct Point { int x, y; }
Simple typeSimple type int i;
Enums typeEnums type enum State { Off, On }
Everything is really an object
![Page 29: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/29.jpg)
29
Refrence typesRefrence types
Interface typeInterface type Delegate typeDelegate type Class typeClass type Array typeArray type
![Page 30: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/30.jpg)
30
Unsafe codeUnsafe code
Unsafe codeUnsafe code Low-level code without leaving the boxLow-level code without leaving the box Enables unsafe casts, pointer arithmeticEnables unsafe casts, pointer arithmetic
Declarative pinningDeclarative pinning fixed statementfixed statement
Basically “inline C”Basically “inline C”
![Page 31: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/31.jpg)
31
Unsafe codeUnsafe codeclass 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);}
![Page 32: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/32.jpg)
32
PropertiesProperties
Properties are “smart fields”Properties are “smart fields” Natural syntax, accessors, inliningNatural syntax, accessors, inlining
class Borrel { private int start; public int Start { get { return start; } set {
if (value < 1700 || 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;
}}
![Page 33: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/33.jpg)
33
IndexersIndexers
Indexers are “smart arrays”Indexers are “smart arrays” Can be overloadedCan 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”]); }}
![Page 34: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/34.jpg)
34
Dogs DemoDogs 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 ClassEnd Namespace
import VirtualDog;
var d = new Dog();var m = new Mopje();
d.RollOver();m.RollOver();
![Page 35: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/35.jpg)
35
What more?What more?
VersioningVersioning XML comments (Demo?)XML comments (Demo?) Conditional compilationConditional compilation ......
![Page 36: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/36.jpg)
36
References and more infoReferences and more info
C# session by Tony Goodhew, C# session by Tony Goodhew, TechEd 2000TechEd 2000
.NET session Eric Meijer.NET session Eric Meijer C# session Eric MeijerC# session Eric Meijer http://www.cs.vu.nl/~pgroene/http://www.cs.vu.nl/~pgroene/
Vakken/Oop/oop.htmlVakken/Oop/oop.html
![Page 37: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/37.jpg)
37
Questions?Questions?
![Page 38: NET and C#](https://reader030.vdocuments.mx/reader030/viewer/2022020102/568148f4550346895db6134c/html5/thumbnails/38.jpg)
38
Where do you what to go today?Where do you what to go today?