“An Introduction to .NET, C# and Visual Studio 2005”

Slides:



Advertisements
Similar presentations
CS Body of Knowledge (ACM) Discrete Structures Programming Fundamentals Algorithms & Complexity Operating Systems Architecture & Organization Social &
Advertisements

Wrap-up: Where Do You Go From Here? MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET Objectives “.NET is the future of software development.
.NET Technology.
Introduction to C# Tom Roeder CS fa. Goals of the course Introduce C# language ECMA standard originally developed by MSR not just Java + C++ many.
CSE3030Lecture 11 Know Your User The First Slogan.
Keith Elder Microsoft MVP It’s the new wave…man…..
2. Developing in.NET and C#. 2 Microsoft Objectives “Microsoft.NET development is based on an underlying framework of tools and classes. These tools and.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Lecture 2: An Introduction to J# and.NET. 2 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 2-2 Objectives “Microsoft.NET is based on the.NET.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 8: WebForms — Web-based.
ISYS 350 Business Application Development
Computer Science 317 Database Management Introduction to Web Access to Databases.
1..NET Architecture Based on slides by Joe Hummel.
Introduction to .Net Framework
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
1 8/29/05CS360 Windows Programming Professor Shereen Khoja.
1 Program Execution in the 21 st Century Modern Software Development in.NET and C# A webcast series for C++, Java, and VB6 developers – Part 1 of 15: [
.NET Overview. 2 Objectives Introduce.NET –overview –languages –libraries –development and execution model Examine simple C# program.
C# A 1 CSC 298 Introduction to C#. C# A 2 What to expect in this class  Background: knowledge of an object oriented language of the C++, Java, … family.
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
.NET Framework & C#.
Introduction to .NET Framework
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
ASSEMBLIES AND THE GAC CHAPTER 1, LESSONS 4-7 & LAB.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 2: Working with Visual.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
1..NET Architecture Based on slides by Joe Hummel.
.NET Framework Danish Sami UG Lead.NetFoundry
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Week 1: THE C# LANGUAGE Chapter 1: Variables and Expressions ➤ Included in Visual Studio.NET ➤ What the.NET Framework is and what it contains ➤ How.NET.
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
Sage ACT! 2013 SDK Update Brian P. Mowka March 23, 2012 Template date: October 2010.
ISYS 350 Business Application Development David Chao.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
Lecture 4: J# Execution Model. 2 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 4-2 Objectives “J# programs execute like any other.NET program.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 2: Working with Visual.
1. The .NET Architecture 1. The .NET Architecture 2003
introductory lecture on java programming
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Text Introduction to.NET Framework. CONFIDENTIAL Agenda .NET Training – Purpose  What is.NET?  Why.NET?  Advantages  Architecture  Components: CLR,
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 15: Java Basics Fundamentals of Web Programming.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 4: Intro to GUIs and the.
ClickOnce Deployment (One-click Deployment)
Lecture 1: The .NET Architecture
Computer System Structures
What is .NET.
Introduction to .NET framework
Android Mobile Application Development
Platform as a Service.
C# and the .NET Framework
Introduction to .NET Framework Ch2 – Deitel’s Book
CE-105 Spring 2007 Engr. Faisal ur Rehman
Java programming lecture one
CMPE419 Mobile Application Development
2.1. Compilers and Interpreters
Part C - Introduction to Programming and the .NET Framework
Introduction to C# AKEEL AHMED.
Advanced Programming: C# Lecture 01: Introduction
Introduction to .NET By : Mr. V. D. Panchal Content :
.Net Framework Details Imran Rashid CTO at ManiWeber Technologies.
(Computer fundamental Lab)
Service Template Creation from the Ground Up
0. Overview of 2-Day Academic .NET Workshop
CMPE419 Mobile Application Development
ClickOnce Deployment (One-click Deployment)
IS 135 Business Programming
C# and ASP.NET Programming
CS313T Advanced Programming language
Presentation transcript:

“An Introduction to .NET, C# and Visual Studio 2005” An Introduction to .NET, C# and VS 2005 “An Introduction to .NET, C# and Visual Studio 2005” Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College hummel@lakeforest.edu Lake Forest College Workshop © 2006 Joe Hummel

Introductions… Joe Hummel, PhD I wear 2 hats: Chicago, USA An Introduction to .NET, C# and VS 2005 Joe Hummel, PhD Chicago, USA email: hummel@lakeforest.edu web: http://mathcs.lfc.edu/hummel blog: http://www.pluralsight.com/blogs/drjoe I wear 2 hats: Academic: Associate Prof. of CS at Lake Forest College (www.lakeforest.edu) PhD from UC-Irvine (Optimizing Compilers, 1998) Industry: consultant and trainer for Microsoft and Pluralsight (www.pluralsight.com) specializing in Microsoft Windows development and .NET training Lake Forest College Workshop © 2006 Joe Hummel

And you? Name? Institution? 1. Introduction An Introduction to .NET, C# and VS 2005 Name? Institution? Lake Forest College Workshop © 2006 Joe Hummel

Workshop Outline Topic Lecture Introduction to .NET and C# 1 An Introduction to .NET, C# and VS 2005 Topic Lecture Introduction to .NET and C# 1 Working with Visual Studio 2005 2 Working with C# 2.0 3 Intro to GUIs and the other .NET Languages 4 WinForms — Windows-based GUIs in .NET 5 Introduction to Web Applications 6 WebForms and ASP.NET 7 Web Services 8 OO and Application Design 9 Relational Databases, SQL, and Visual Studio 10 Database Programming with ADO.NET 11 Lake Forest College Workshop © 2006 Joe Hummel

Daily Schedule Sunday: lecture & lab #1 Monday: lectures & labs #2-5 6:00-8:00 Monday: lectures & labs #2-5 9am-noon 1:30-5:00 7:00-9:00 Tuesday: lectures & labs #6-9 Wednesday: lectures & labs #10-11

Resources Workshop materials are available here: 1. Introduction An Introduction to .NET, C# and VS 2005 Workshop materials are available here: http://mathcs.lfc.edu/hummel/workshops.htm PPT, demos, and lab exercises Past & future workshops available here as well Blog discussing updates, new happenings, etc: http://www.pluralsight.com/blogs/drjoe Other .NET sites: Microsoft Developer Network: http://msdn.microsoft.com/ MSDN Academic Alliance: http://msdn.microsoft.com/academic/ Microsoft’s sourceforge-like project site: http://www.codeplex.com/ Good sites for .NET code, discussions, etc: http://www.devsource.com/ http://www.gotdotnet.com/ http://www.asp.net/ MSDN proper is for professional developers MSDN Academic Alliance is specifically for academia: curriculum repository, MSDNAA software program, etc. Lake Forest College Workshop © 2006 Joe Hummel

1.1 Why use .NET Advantages How I use .NET 1. Introduction An Introduction to .NET, C# and VS 2005 Advantages How I use .NET Lake Forest College Workshop © 2006 Joe Hummel

Advantages of .NET Support for multiple languages: 1. Introduction An Introduction to .NET, C# and VS 2005 Support for multiple languages: C#, C++, VB, J# (aka Java 1.2), … same concepts, same tools — from any language Support for different types of applications: console, desktop GUI, web-based GUI, web services, mobile, … Industrial strength tools & technologies at reasonable price Visual Studio .NET is a great environment that students like Available from MSDNAA — MSDN Academic Alliance http://www.msdnaa.net allows you to legally distribute software to faculty & students Visual Studio, Windows, SQL Server, Visio, SharePoint, … Lake Forest College Workshop © 2006 Joe Hummel

.NET at Lake Forest College 1. Introduction An Introduction to .NET, C# and VS 2005 Lake Forest is a small, 4-year liberal arts college near Chicago Standard Java-based intro sequence (CS0-1-2) We use command-line and BlueJ We do *not* use .NET since Java support is too far out-of-date Upper-division courses: Operating Systems: C on Linux Programming languages: ML at command-line, SQL & VB.NET Compiler class: J# or C# in .NET Web development: LAMP (Linux, Apache, MySQL, Perl) Senior Capstone: students choose platform (most choose .NET) Lake Forest College Workshop © 2006 Joe Hummel

Demos… Here are some of the applications students develop: Fun: 1. Introduction An Introduction to .NET, C# and VS 2005 Here are some of the applications students develop: Fun: Desktop GUI SlideShow app Desktop GUI Google-based app (using Google’s web service) CS 1-2: GUI-based census data analyzer Shape inheritance hierarchy within GUI-based app AVL trees with GUI visualizer and NUnit test harness Programming Languages: Database-driven GUI apps GUI front-ends to web services (Google, Amazon, etc.) Senior capstone: GUI-based scheduling program Common theme: GUI-based applications (desktop or web) to make things more interesting… Lake Forest College Workshop © 2006 Joe Hummel

1.2 Quick Intro to .NET .NET at the command line 1. Introduction An Introduction to .NET, C# and VS 2005 .NET at the command line Lake Forest College Workshop © 2006 Joe Hummel

Command-line Development 1. Introduction An Introduction to .NET, C# and VS 2005 Available via the Microsoft .NET Framework SDK same idea as Java and the JDK SDK = Software Development Kit (100 MB download) free, complete set of command-line tools and docs http://msdn.microsoft.com/net install as a standalone product installed by default when you install Visual Studio Note: development requires a “modern” version of Windows Windows NT, 2000, 2003, XP, or Vista Lake Forest College Workshop © 2006 Joe Hummel

Example Program in C# Compute the maximum speed of a sailboat: 1. Introduction An Introduction to .NET, C# and VS 2005 Compute the maximum speed of a sailboat: /* hullspeed.cs */ public class App { public static void Main() string input; double len, speed; System.Console.WriteLine("**Hullspeed Program **"); System.Console.WriteLine(); System.Console.Write("Enter sailboat length (feet): "); input = System.Console.ReadLine(); len = System.Convert.ToDouble(input); speed = 1.34 * System.Math.Sqrt(len); System.Console.WriteLine("Hullspeed = " + speed + " knots"); } }//class Lake Forest College Workshop © 2006 Joe Hummel

Namespaces In .NET, everything is contained within a class 1. Introduction An Introduction to .NET, C# and VS 2005 In .NET, everything is contained within a class Classes nested within namespaces to help organize things a namespace is a named collection of types the System namespace denotes the outermost .NET namespace Example: System.Console.WriteLine("..."); System namespace in FxCL Namespaces are the equivalent of Java packages Console class WriteLine method Lake Forest College Workshop © 2006 Joe Hummel

FxCL .NET Framework Class Library contains 1000's of classes 1. Introduction An Introduction to .NET, C# and VS 2005 .NET Framework Class Library contains 1000's of classes Much like Java’s JCL Organized by namespaces: System System.Data System.Windows.Forms etc. Lake Forest College Workshop © 2006 Joe Hummel

Compile and Run To compile with Framework SDK, use the C# compiler 1. Introduction An Introduction to .NET, C# and VS 2005 To compile with Framework SDK, use the C# compiler open Visual Studio .NET Command Prompt so path is set csc is the command-line C# compiler use /t:exe option to build console-based EXE use /out: option to specify name of EXE c:\> csc /t:exe /out:HullspeedApp.exe hullspeed.cs Microsoft (R) Visual C# .NET Compiler version 8.00.50727.42 for Microsoft (R) .NET Framework version 2.0.50727 Copyright (C) Microsoft Corporation 2001. All rights reserved. c:\> HullspeedApp.exe **Hullspeed Program** Enter sailboat length (feet): 36.25 Hullspeed = 8.06786836779084 knots Lake Forest College Workshop © 2006 Joe Hummel

1.3 Quick Intro to C# C# is essentially Java… 1. Introduction An Introduction to .NET, C# and VS 2005 C# is essentially Java… Lake Forest College Workshop © 2006 Joe Hummel

Example — a Student Class in C# 1. Introduction An Introduction to .NET, C# and VS 2005 /* student.cs */ public class Student { private string ID; private int Exam1, Exam2; public Student(string ID, int exam1, int exam2) // constructor this.ID = ID; this.Exam1 = exam1; this.Exam2 = exam2; } public override string ToString() double avg = (Exam1 + Exam2) / 2.0; string msg = string.Format("Student {0}: average={1}", ID, avg); return msg; }//class Lake Forest College Workshop © 2006 Joe Hummel

Example — Main Program in C# 1. Introduction An Introduction to .NET, C# and VS 2005 Input data, create Student object, and output to screen: /* main.cs */ public class App { public static void Main() Student s; string id; int exam1, exam2; System.Console.WriteLine("Please enter id and 2 exam scores:"); id = System.Console.ReadLine(); exam1 = System.Convert.ToInt32( System.Console.ReadLine() ); exam2 = System.Convert.ToInt32( System.Console.ReadLine() ); s = new Student(id, exam1, exam2); System.Console.WriteLine( s ); // calls ToString to write obj } }//class Lake Forest College Workshop © 2006 Joe Hummel

Compile and Run 1. Introduction An Introduction to .NET, C# and VS 2005 Once again, we use the C# compiler at the command line: remember to open Visual Studio .NET Command Prompt so path is set c:\> csc /t:exe /out:StudentApp.exe main.cs student.cs Microsoft (R) Visual C# .NET Compiler version 8.00.50727.42 for Microsoft (R) .NET Framework version 2.0.50727 Copyright (C) Microsoft Corporation 2001. All rights reserved. c:\> StudentApp.exe Please enter id and 2 exam scores: 123456 87 92 Student 123456: average=89.5 Lake Forest College Workshop © 2006 Joe Hummel

1.4 Execution Model How does .NET execute? 1. Introduction An Introduction to .NET, C# and VS 2005 How does .NET execute? Lake Forest College Workshop © 2006 Joe Hummel

.NET Framework Class Library (FxCL) Common Language Runtime (CLR) Architecture 1. Introduction An Introduction to .NET, C# and VS 2005 Multi-language, virtual machine driven… C# C++ VB J# … Your Application .NET Framework Class Library (FxCL) Common Language Runtime (CLR) Operating System Hardware Lake Forest College Workshop © 2006 Joe Hummel

Execution Model .EXE is *not* a standalone program (think "Java") 1. Introduction An Introduction to .NET, C# and VS 2005 .EXE is *not* a standalone program (think "Java") When run .EXE, Windows loads CLR, which loads .EXE/FxCL CLR is a VM that JITs native code on a per-method basis… .EXE OS Process CLR JIT Compiler other FxCL components Core FxCL obj code Underlying OS and HW Lake Forest College Workshop © 2006 Joe Hummel

Viewing Compiled Code with ILDasm 1. Introduction An Introduction to .NET, C# and VS 2005 ILDasm = IL Disassembler IL = Microsoft's Intermediate Language equivalent to Java bytecodes (abstract, stack-based, verifiable) c:\> ildasm StudentApp.exe Note once again that StudentApp only contains the classes we wrote; the FxCL classes are loaded dynamically by the CLR as needed. Be sure to open Microsoft Visual Studio .NET Command Prompt to ensure path is set so ILDasm tool can be found. Want to reverse engineer .NET back into C# or VB? See Reflector: http://www.aisto.com/roeder/dotnet/ Lake Forest College Workshop © 2006 Joe Hummel

Where is .NET Installed? CLR is a normal Windows DLL 1. Introduction An Introduction to .NET, C# and VS 2005 CLR is a normal Windows DLL FxCL resides in the GAC GAC = Global Assembly Cache see the folder "C:\Windows\Assembly" Observations: some assemblies have been pre-JIT’d ("native image") assemblies are tamper proof via digital signatures GAC is version-aware — can hold different versions of component Does .NET use a CLASSPATH like Java? No! .NET searches the GAC first, then the same folder as .EXE Search can be customized with .config file Lake Forest College Workshop © 2006 Joe Hummel

Implications? Users need CLR & FxCL to run .NET applications 1. Introduction An Introduction to .NET, C# and VS 2005 Users need CLR & FxCL to run .NET applications Available via Redistributable .NET Framework (20MB download) runs on Windows 98 and above .NET applications are version-specific: app is dependent upon version of .NET it was compiled against application will *NOT* run unless that version of .NET is installed compiled with SDK 1.0 / VS .NET 2002? .NET v1.0 must be installed compiled with SDK 1.1 / VS .NET 2003? .NET v1.1 must be installed compiled with SDK 2.0 / VS .NET 2005? .NET v2.0 must be installed Much like Java, .NET execution model is about trade-offs: managed execution (more secure, memory protection, etc.) portability slower execution (10%?) How can you tell if .NET has been installed on a machine? Look for the presence of the GAC, and then the version numbers on the assemblies. Lake Forest College Workshop © 2006 Joe Hummel

.NET is Portable? Much of .NET is ECMA standardized Available on a variety of platforms: various flavors of Windows (including CE and Mobile versions) Linux / OS X: Mono project supported by Novell (very mature) http://www.mono-project.com/ Unix: dotGNU (much less mature) http://www.dotgnu.org/ FreeBSD / OS X: Rotor / SSCLI Microsoft's shared-source release of .NET for research purposes http://msdn.microsoft.com/net/sscli

1.5 What's Next? Lab exercise #1 1. Introduction An Introduction to .NET, C# and VS 2005 Lab exercise #1 Lake Forest College Workshop © 2006 Joe Hummel