0% found this document useful (0 votes)
46 views25 pages

Introduction To C#: Tom Roeder CS 215 2006fa

The document introduces a course on C# and the .NET framework. The goals are to introduce the C# language and .NET framework. It will not teach programming fundamentals but expects students to have object-oriented experience. The course will use Visual C# Express and assignments will be pass/fail. The syllabus outlines lectures on C# constructs, .NET memory management, and topics like generics and reflection over 10 weeks.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views25 pages

Introduction To C#: Tom Roeder CS 215 2006fa

The document introduces a course on C# and the .NET framework. The goals are to introduce the C# language and .NET framework. It will not teach programming fundamentals but expects students to have object-oriented experience. The course will use Visual C# Express and assignments will be pass/fail. The syllabus outlines lectures on C# constructs, .NET memory management, and topics like generics and reflection over 10 weeks.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

Introduction to C#

Tom Roeder CS 215 2006fa

Goals of the course

Introduce C# language

ECMA standard originally developed by MSR not just Java + C++ many extensions future of Windows base of Microsofts C# implementation

Introduce .NET framework


Non-goals

Teach you to program

should be very comfortable writing OO code we will not cover much if any basic programming not even teach you OO style (except wrt C#) expected to write all code in OO style S/U only even homework

Introduce object oriented languages

Give you a detailed grade


S/U Details

Requirements for the course

come to lecture participate do three assignments will not be giving a detailed grade show me that you understand the concepts, and can write C# code

Assignments are S/U


All three assignments will be online soon

must be completed by the end of the course

Administrative Details

Class time MWF 12:20-1:10 office hours: W 10:30-12 or by appointment

tmroeder@cs.cornell.edu (4112 Upson) really: experience in OO coding/concepts Do not submit work that is not your own minimum penalty: U in the course

Prerequisites: CS 211/212

Academic Integrity

Useful Tools

Visual C#

Express: Google Visual C# Express in Visual Studio: MSDNAA

must be version 2005: we need C# 2.0

Mono: http://www.go-mono.com

Open Source impl for Linux: not quite at 2.0 Shared Source impl for Windows (through 2.0) Used to work on BSD / OS X, too

Rotor: http://msdn.microsoft.com/net/sscli

Useful Tools

Portable.NET: http://www.dotgnu.org

yet another open source impl we will use this for homework turn on your email notifications!

CMS: http://cms.csuglab.cornell.edu

Course Webpage: http://www.cs.cornell.edu/courses/cs215


will post lectures online as well as any errata for the homework

CSUGLab

You all will have accounts

MSDNAA access: let me know if you dont currently have it http://www.csuglab.cornell.edu/userinfo.html Visual Studio .NET 2005 should be installed there

Syllabus

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

Quiz 1

Each class will begin with a quiz


not for credit but for knowledge but I will collect them and see what you know OO programming, mainly to do with Java If you dont know Java, but do have OO experience, its OK talk to me after if you have trouble

Todays quiz will be on prerequisites


What is .NET?

A Framework in which to run code A Common Language Runtime (CLR)


runs all programs C# compiles to Microsoft Intermediate Language MSIL runs on CLR Virtual Machine like Java code written in many languages compiles to MSIL

A Common Language Specification (CLS) A Common Type System (CTS)

What is .NET?
Web Services
Sharepoint ... ...

Building Blocks (e.g. for Services)

.NET Applications Languages:


C#, Visual Basic, etc

Enterprise Servers
SQL Server BizTalk ...

Runtime
Common Type System Common Language Runtime

Services: .NET and COM+

.NET Framework
Operating System

From MSDN

What is the CLR?


Base Class Library Support Thread Support Type Checker Security Engine MSIL to Native Compilers (JIT) Code Manager Class Loader From MSDN COM Marshaler Exception Manager Debug Engine Garbage Collector (GC)

What is the CTS?

A set of common types


any language that runs in CLR should implement no syntax specified Languages often define aliases CTS defines System.Int32 4 byte integer C# defines int as an alias of System.Int32

For example

What is the CTS?

From MSDN

What is the CLS?

A specification of language features

how methods may be called when constructors are called subset of the types in CTS are allowed

For example

Code that takes UInt32 in a public method UInt32 is not in the CLS not marked is assumed to mean not compliant

Can mark classes as CLS-compliant

The 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


C#, C++, J#, Visual Basic even have Python (see IronPython)

Many languages run on .NET framework

Assemblies

Code contained in files called assemblies


code and metadata .dll as before to run: public static


types

void Main(string[] args)

private: local directory, not accessible by others

eg. Wolfram .NETLink

shared: well-known location, can be GAC strong names: use crypto for signatures

then can add some versioning and trust

COM 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 software engineering problems not type safe at all

Difficult to get right


ASP.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 in the manner of ODBC provides classes for access

Use the CLR to access databases


Windows 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?

First C# Program
using System; namespace Test { int a = 137; class Hello { public static void Main(string[] args) { Console.WriteLine(Hello {0}, a); } } }

Constructions of Note

using

like import in Java: bring in namespaces disambiguation of names like Internet hierarchical names and Java naming like in Java single inheritance up to object

namespace

class

Constructions 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

More C# : basic inheritance


class A { protected int a; public virtual void print() { Console.WriteLine(a = + a); } } class B : A { public override void print() { Console.WriteLine(a really = + (a + 137)); } }

You might also like