should be very comfortable writing OO code we will not cover much if any basic programming languages not even teach you OO style except wrt C# expected to write all code in OO st
Trang 1Introduction to C#
Tom Roeder
CS 215 2006fa
Trang 2Goals of the course
Trang 3 should be very comfortable writing OO code
we will not cover much if any basic programming
languages
not even teach you OO style (except wrt C#)
expected to write all code in OO style
S/U only
Trang 4 will not be giving a detailed grade
show me that you understand the concepts, and can write C# code
soon
must be completed by the end of the course
Trang 5 Do not submit work that is not your own
minimum penalty: U in the course
Trang 6Useful Tools
Visual C#
Express: Google “Visual C# Express”
in Visual Studio: MSDNAA
Mono: http://www.go-mono.com
Open Source impl for Linux: not quite at 2.0
Rotor:
http://msdn.microsoft.com/net/sscli
Shared Source impl for Windows (through 2.0)
Used to work on BSD / OS X, too
Trang 7Useful Tools
yet another open source impl
we will use this for homework
turn on your email notifications!
://www.cs.cornell.edu/courses/cs215
will post lectures online
as well as any errata for the homework
Trang 8 You all will have accounts
MSDNAA access: let me know if you don’t
currently have it
http://www.csuglab.cornell.edu/userinfo.html
Visual Studio NET 2005 should be installed there
Trang 9 Syllabus (10 more lectures)
C# constructs: 5 lectures
Types, Delegates, Generics, Reflection, Iterators
NET Memory Management: 1 lecture
Topics: 4 lectures
C# 3.0, Threading, Security, MSIL, MSH
Trang 10Quiz 1
Each class will begin with a quiz
not for credit but for knowledge
but I will collect them and see what you know
Today’s quiz will be on
prerequisites
OO programming, mainly to do with Java
If you don’t know Java, but do have OO
experience, it’s OK
talk to me after if you have trouble
Trang 11What is NET?
(CLS)
Trang 12Common Language Runtime
Building Blocks (e.g for Services)
Services: NET and COM+
SQL Server BizTalk
Languages : C#, Visual Basic, etc
Trang 13What is the CLR?
Class Loader
MSIL to Native Compilers (JIT)
Code Manager
Garbage Collector (GC)
Security Engine Debug Engine Type Checker Exception Manager Thread Support COM Marshaler
Base Class Library Support
Trang 14What is the CTS?
A set of common types
any language that runs in CLR should implement
no syntax specified
Languages often define aliases
For example
CTS defines System.Int32 – 4 byte integer
C# defines int as an alias of System.Int32
Trang 15What is the CTS?
Trang 16What is the CLS?
features
how methods may be called
when constructors are called
subset of the types in CTS are allowed
Code that takes UInt32 in a public method
UInt32 is not in the CLS
not marked is assumed to mean not compliant
Trang 17The Class Libraries
The common classes used in many
programs
like Java Class Library
eg.
System.Console.WriteLine
XML, Networking, Filesystem, Crypto, containers
Can inherit from many of these classes
Many languages run on NET framework
C#, C++, J#, Visual Basic
Trang 18 private: local directory, not accessible by others
shared: well-known location, can be GAC
strong names: use crypto for signatures
Trang 19COM vs NET
Historically, COM provided this integration
support for interfaces and interaction
given a GUID, lookup the type library
dynamically instantiate class
do RPC to make calls in many cases
Difficult to get right
software engineering problems
not type safe at all
Trang 20ASP.NET and ADO.NET
Use NET languages in web pages
thus can write typesafe code
server-side or client-side
Sharepoint interactions
can log in
Use the CLR to access databases
in the manner of ODBC
provides classes for access
Trang 21Windows PowerShell
New shell originally for MS Vista
available for WinXP/2k3
native NET
instantiates arbitary NET classes and accesses them
Also can access COM objects
Allows better interaction with
programs
Can it surpass bash and others?
Trang 22}
}
Trang 24Constructions of Note
Console.Write(Line)
Takes a formatted string: “Composite Format”
Indexed elements: e.g., {0}
can be used multiple times
only evaluated once
{index [,alignment][:formatting]}
also can use as in Java
“Test “ + a
Trang 25More C# : basic inheritance
}