Unformatted text preview:

Introduction to .NET, C#, and Visual StudioC# ProgrammingJanuary 8Part IAdministriviaAdministrivia•When: Wednesdays 10–11am (and a few Mondays as needed)•Where: Moore 100B•This lab has Windows machines, but feel free to bring laptops•Office Hours: to be announced•Course webpage:http://www.seas.upenn.edu/~cse39905Course Structure•No quizzes, no exams•Roughly 6 projects•Roughly 2 weeks per project•The final project will be slightly longer and more open-ended•Projects will be due at midnight on the night of the deadline•All assignments should be submitted through the BlackboardDigital Dropbox•Late policy: 15% off each day, up to 3 days lateFinal Project•Your chance to choose your own project•Brainstorming and planning will begin after spring break•Top projects will be entered into the Xtreme.NET Challenge– hopefully there will be 20 top projects :-)•First prize: Xbox 360!•Judges will include someone from Microsoft recruiting, maybesomeonefromtheC#team•More details to come athttp://www.seas.upenn.edu/~cse39905/xtremePart IIWhat is .NET?The Microsoft .NET Framework•.NET is a development platform that launched in 2000•Goals include language independence, language integration,web services•Technologies to promote rapid development of secure,connected applications•.NET components include:•Languages (C#, VB, Visual C++, Visual J#, ...)•Common Language Runtime (CLR)•Framework Class Library (FCL)Common Language Runtime•A single runtime environment to execute programs written inany .NET language•Includes a virtual machine•Activates objects, manages memory, performs security checks,collects garbage•TorunontheCLR,alanguagemustadheretoaCommonLanguage Specification (CLS)•A language must also build upon base types specified in theCommon Type System (CTS)Languages•Language compilerstranslatesourceintoMicrosoft IntermediateLanguage (MSIL). Theparticular syntax of alanguage is unrestricted.(Language independence)Languages•Since each languagetargets the same IL withthesamebasetypesystem, objects written inany .NET language canextend, implement, andinteract with any other.NET objects.(Language integration)List of .NET Languages(http://www.dotnetpowered.com/languages.aspx)AdaAPLAsmLBasicBETABFBooCC#C++CamlCATCobolCULEE#EiffelF#FlashForthFortranG#HaskellIL/MSILJavaJavaScriptLexicoLISPLOGOLuaMercuryModulaMondrianOberonNemerlePanPerlPascalPHPProcessingPrologPythonRubyRPGScalaSchemeSmalltalkSMLSprySynergyTcl/TkZonnonCommon Language Runtime•The result of compilation – ie, MSIL – is not machine code•At runtime, this intermediate code is Just In Time (JIT)compiled into machine instructions to execute•Methods are JITed as they are needed, and cached for futureuse•JITing allows optimizations based on the environment of therunning programFramework Class Library•Bottom layer contains classes that support:•input and output•string manipulation•security management•network communication•thread management•text manipulation•reflection•collections functionality•etc.•Next layer contains classes that support management of SQLand XML data•Top layer supports application development•Windows Forms•Web Forms•Web ServicesBenefits of .NETFrom the ground up...•The CLR abstracts away low-level details of the processorarchitecture and of Windows system calls•It also manages memory automatically•The FCL provides a rich collection of classes to build upon,including convenient ways of connecting to remote data stores•The Windows Forms, Web Forms, and Web Service librariesfacilitate rapid development of rich interface applications,both desktop and web•Applications written in any .NET language can interoperatewith each otherPart IIIWhat is C#?Language Features•C# is the .NET language of choice for serious development•(VB.NET is also very expressive, but gets a bad rap)•A modern object-oriented language with its roots in C, C++,and Java•C# 2.0 (and .NET 2.0) released in November 2005•New features included generics and anonymous methods•C# 3.0 (and .NET 3.0) planned for 2007•New language features will include anonymous types, lambdaexpressions, and Language Integrated Query (LINQ)Language Features•Built-in value types (byte, char, bool, int, float, double,decimal, long, struct, enum,etc.)•Classes, partial class definitions•Single inheritance•Interfaces•Structs•Delegates (“type-safe function pointers”)•Properties (in place of getters and setters)•Operator overloading•Preprocessor directives•Unsafe manipulation of pointers directly•Commenting that generates documentationPart IVHello WorldVisual StudioBefore we can write the simplest of programs, we need to becomefamiliar with the Visual Studio development environment.•Visual Studio facilitates rapid development with its FormDesigner•This allows the programmer to literally drag-and-drop GUIelements onto their window (or form)•Double-clicking a form element creates a function (or eventhandler) that responds to that control’s particular events•Visual Studio’s Form Designer has long been around for VisualBasic development•It now offers this rich GUI development environment to all.NET languagesMore on this next time...Creating a Console AppCreating a Console AppIf you choose to create a directory for solution, then all projectsthat are created within the solution will reside in the same folderProject Organization•A solution is a collection of projects•Projects can be added and removed from a solution freely –you can organize a solution to contain related projects forsimplicity•To prevent naming conflicts, the namespace keyword restrictswhen classes are in scope•YoucanthinkofanamespaceasaJavapackage•To refer to a class Foo in namespace Moo, you would writeMoo.Foo•If you write using Moo; outside of the namespace and classdeclarations, you can use Foo without qualificationHello Worldusing System;namespace HelloWorld{class Hello{static void Main(string[] args){Console.WriteLine("Hello world!");}}}Compiling and Running•To build the entire solution, F6•To build the current project, Shift + F6•To run the main project without debugging, Shift + F5•To run the main project with debugging, F5Compiling and Running•To build the entire solution, F6•To build the current project, Shift + F6•To run the main project without debugging, Shift + F5•To run the main project with debugging, F5Part VSome


View Full Document

Penn CIS 399 - CIS 399 LECTURE NOTES

Download CIS 399 LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CIS 399 LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CIS 399 LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?