Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
NET and C#
Objectives
Microsoft 2
Part 1
Microsoft 3
Recall assemblies
code.vb
code.vb
code.cs
Development Tools
.EXE / .DLL
assembly
Microsoft 4
.NET development
• other platforms?
– FreeBSD / Mac OS X via Rotor (i.e. SSCLI)
– Linux via Mono project
Microsoft 5
Development options, cont'd
3) free IDEs
• #develop, a simplified clone of VS.NET
• WebMatrix, for building web-based applications
Microsoft 6
Hello World in C#
/* hello.cs */
}//class
hello.cs
Microsoft 7
Why System.Console prefix?
• In .NET, all code & data must live within a module / class
• Often nested within namespaces to help organize things
– a namespace is really just a named collection
• Example:
System.Console.WriteLine("Hello World!");
System
namespac
e
in FCL
Consol
e
class
WriteLine
subroutin
Microsoft e 8
Compiling and running
c:\> hello.exe
Hello World!
Microsoft 9
Viewing an assembly with ILDasm
Microsoft 10
IL?
Microsoft 11
Part 2
• Development on FreeBSD…
Microsoft 12
Development on FreeBSD
Microsoft 13
Part 3
Microsoft 14
C#
• Case-sensitive
• Strict type-checking
• Operator and method overloading
• Single public inheritance; any number of interfaces
• All classes inherit from object; classes may be nested
• Garbage-collected
Microsoft 15
Part 4
• Class-based development…
Microsoft 16
A customer class
/* customer.cs */
• Here's the source code for Main, using our Customer class:
/* main.cs */
}//class
Microsoft 18
Compiling and running application
c:\> app.exe
Customer: joe hummel
Microsoft 19
Part 5
• Component-based development…
Microsoft 20
Example
main.cs customer.cs
app.exe + customer.dll
Microsoft 21
Compiling a component
Microsoft 22
Compiling and running application
c:\> app.exe
Customer: joe hummel
Microsoft 23
Where are references stored?
Microsoft 24
mscorlib?
• mscorlib = "ms-core-lib"
• Core FCL assembly
– contains core system classes like string
– contains System.Console class for console-based I/O
Microsoft 25
Recall CLR-based execution
• All assemblies must be present:
.DLL
.EXE .DLL
.DLL
OS Process
other FCL
JIT Compiler
assemblies
CLR
Underlying OS and HW
Microsoft 26
Summary
• .NET is multi-language
– Framework SDK based on C# and VB.NET
– lots of other languages available
Microsoft 27
References
• Books:
– J. Richter, "Applied Microsoft .NET Framework Programming"
• Web sites:
– http://msdn.microsoft.com/net
– MSDNAA: http://www.msdnaa.net/
– Rotor (SSCLI): http://msdn.microsoft.com/net/sscli
– Mono: http://www.go-mono.com/
– Free IDEs:
• http://www.icsharpcode.net/OpenSource/SD/default.asp
• http://www.asp.net/webmatrix/
– Anakrino reverse-engineering tool:
• http://www.saurik.com/net/exemplar/
Microsoft 28
Lab?
Microsoft 29