Upload
others
View
7
Download
0
Embed Size (px)
Citation preview
6/1/2009
1
Intro to C#
Head First C#
6/1/2009
2
Programming Coverage
Methods, Classes, ArraysClasses, Arrays
Iteration, Control Structures
Variables, Expressions
Data Types
Who is this book for?
• Do you want to Learn C#?• Do you like to tinker – do you learn by doing• Do you like to tinker do you learn by doing rather than by reading?
• Do you prefer stimulating dinner conversation to dry, dull academic lectures?
• Does the idea of writing code make you bored and a little twitchy?
• Are you a kick‐butt C++ or Java programmer looking for a reference book?
• Are you afraid to try something different?
6/1/2009
3
Book’s Design
• Brain craves novelty
Head First Principles
• Make it visual• Conversational, casual style instead of formal, lecture style, y , y• Challenge the learner to think• Get the learner’s attention
– Uses unexpected images and techniques• Touch the learner’s emotions• Redundancy
– Same topic presented multiple times in different ways for lti l l i t lmultiple learning styles
• Different activities to learn and remember when doing, not just when reading
6/1/2009
4
Bend Your Brain Into Submission
1. Slow down. The more you understand the l h t iless you have to memorize.
2. Do the exercises. Write your own notes.
3. Read the “There are no Dumb Questions” sections.
4 Make this the last thing you read before bed4. Make this the last thing you read before bed, or the last challenging thing.
5. Drink lots of water.
Bend Your Brain Into Submission
6. Talk about it. Out loud.
7. Listen to your brain. Pay attention when it feels overloaded or you find yourself skimming.
8. Feel something. Your brain needs to feel that it mattersit matters.
9. Write a lot of software!
6/1/2009
5
Activities and Exercises
• The activities and exercises are part of the t t f th b kcore content of the book.
• They are not optional!
• Ok to peek at the solutions in the book, but you should try to solve them firstyou should try to solve them first.
• We will do some similar activities and exercises in class.
C# Demonstration Walkthrough
• Try this on your computer
• Will introduce C#.NET and the Visual Studio IDE – Integrated Development Environment –which is a program used to write programs
6/1/2009
6
Contacts Database
Structure of our ProgramProgram
6/1/2009
7
Contacts Database
• Start up Visual Studio, follow along b k/l tbook/lecture
• Points to make:– IDE creates files for you from a template
– Major windows of the IDE
– Reset layoutReset layout
6/1/2009
8
Contacts Database
• Add picturebox to form– Insert logo graphic from http://www.headfirstlabs.com/books/hfcsharp/
– Will need to download and unzip the file
Picturebox Click Event
• Double‐click on the picturebox to add an t Thi i ll d th d T th devent. This is called a method. Type the code
inside the curly braces:
private void pictureBox1_Click(object sender, EventArgs e){
MessageBox.Show("Contact list 1.0.\nWritten by: Kenrick Mock", "About");MessageBox.Show( Contact list 1.0.\nWritten by: Kenrick Mock , About );}
6/1/2009
9
Run your program
Click Green Triangle
• Where are my files?
Next Steps
• See book/lecture for details– Add database
– Add “People” Table
6/1/2009
10
Who Does What?
Complete The Table
Also, type in sample data into the table (see in class)
6/1/2009
11
Connect Database
• Add new databaseAdd d t• Add new data source
• Drag onto form– Click “Detail” for separate fields– Configure text/font/etc.
• Test Drive
• Skip installer, database diagram
6/1/2009
12
Intro to Computing
(From C# Software Solutions)
6/1/2009
13
The CPU
• Fetches instructions from main memory
• Carries out the operations commanded by the• Carries out the operations commanded by the instructions
• Each instruction produces some outcome
• A program is an entire sequence of instructions
d b b• Instructions are stored as binary numbers
• Binary number ‐ a sequence of 1’s and 0’s
Main Memory – a big list of addresses
6/1/2009
14
The Fetch‐Decode Execute Cycle
• Bit: smallest and most basic data item in a computer; represents a 0 or a 1
Knowing About: Computer Hardware
represents a 0 or a 1
• Byte: a grouping of eight bits
– E.g., 00010001
– What does this represent?
• Word: a grouping of one or more bytes
6/1/2009
15
6/1/2009
16
Bits could represent characters
We said that 00010001 could representanything a number sound color etc
Bits could represent sound
anything, a number, sound, color, etc.
6/1/2009
17
Layers of Programming Languages
6/1/2009
18
Layers of Software Systems
OperatingSystem
ApplicationsBIOSCPU
The .NET Platform• C# .NET is in a sense one step removed from a typical high‐
level language
• C# runs using a “Virtual Machine” or “Common Language Runtime”
– The physical computer simulates a virtual computer that runs your program
.NET Software
.NET Software .NET Program
6/1/2009
19
.NET FrameworkC# VB.NET C++.NET OtherC# VB.NET C++.NET Other
Common Language SpecificationCommon Language Specification
Framework Class LibraryFramework Class Library
ADO.NET XML Threading IO
VisualVisualStudioStudio.NET.NET
Windows FormsWindows FormsASP.NETASP.NETWeb Services
ASP.NET Application Services
Web Forms ControlsControls Drawing
Windows Application Services
Network Security Diagnostics Etc.
Common Language RuntimeCommon Language Runtime
Memory Management Common Type System Lifecycle Monitoring
Operating SystemOperating System