Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.

Slides:



Advertisements
Similar presentations
An Introduction to Programming with C++ Fifth Edition Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Advertisements

The Web Warrior Guide to Web Design Technologies
 2005 Pearson Education, Inc. All rights reserved Introduction.
Chapter 1: Introduction
Programming Creating programs that run on your PC
Introduction To Computers and Programming Lecture 2: Your first program Professor: Evan Korth New York University.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Three types of computer languages
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
Introduction to Computing and Programming
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Creating a Console Application with Visual Studio
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
Your Interactive Guide to the Digital World Discovering Computers 2012.
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
A First Program Using C#
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Microsoft Visual Basic 2005: Reloaded Second Edition
Chapter 1: Creating Java Programs
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Teacher: Ms. Olifer MICROSOFT VISUAL STUDIO 2010: PROPERTIES OF WINDOWS FORM OBJECT.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Programming With C.
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.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Classes CS 21a: Introduction to Computing I First Semester,
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Chapter Three The UNIX Editors.
1.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 1: Introduction to Computers and Programming.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
IS 350 Course Introduction. Slide 2 Objectives Identify the steps performed in the software development life cycle Describe selected tools used to design.
CSC201: Computer Programming
C# and the .NET Framework
Microsoft Office Illustrated
C# Programming: From Problem Analysis to Program Design
CIS16 Application Development Programming with Visual Basic
Topics Introduction Hardware and Software How Computers Store Data
Classes CS 21a: Introduction to Computing I
Computer Programming-1 CSC 111
Presentation transcript:

Chapter 1: A First Program Using C#

Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software comes in two broad categories – System software – Application software Machine language – Expressed as a series of 1s and 0s 1s represent switches that are on, and 0s represent switches that are off 2Microsoft Visual C# 2012, Fifth Edition

Programming (cont’d.) Part of the HelloWorld Program in machine language 3

Programming (cont’d.) High-level programming language – Uses reasonable terms such as “read,” “write,” or “add” instead of the sequence of on/off switches that perform these tasks – Allows you to assign reasonable names to areas of computer memory – Has its own syntax (rules of the language) Compiler – Translates high-level language statements into machine language 4Microsoft Visual C# 2012, Fifth Edition

Programming (cont’d.) Programming logic – Involves executing the various statements and procedures in the correct order to produce the desired results Debugging – The process of removing all syntax and logical errors from the program – Syntax errors are discovered through compilation – Logical errors are discovered through testing 5Microsoft Visual C# 2012, Fifth Edition

Features of Object-Oriented Programming Languages Class – A category of objects or a type of object – Describes the attributes and behaviors of every object that is an instance, or object, of that class Object – An instance of a class – Contains its own set of attribute values 6Microsoft Visual C# 2012, Fifth Edition

The C# Programming Language Developed as an object-oriented and component- oriented language Part of Microsoft Visual Studio 2012 Allows every piece of data to be treated as an object and to consistently employ the principles of object- oriented programming Contains a GUI interface that makes it similar to Visual Basic 7Microsoft Visual C# 2012, Fifth Edition

The C# Programming Language (cont’d.) Modeled after the C++ programming language – However, eliminates some of the most difficult features to understand in C++ Very similar to Java – In C#, simple data types are objects 8Microsoft Visual C# 2012, Fifth Edition

Writing a C# Program that Produces Output literal string argument method class namespace 9Microsoft Visual C# 2012, Fifth Edition

Writing a C# Program that Produces Output (cont’d.) Namespace – Provides a way to group similar classes – Can be used to avoid naming conflicts in large projects C# method parts – Method header Includes the method name and information about what will pass into and be returned from a method – Method body Contained within a pair of curly braces and includes all the instructions executed by the method 10Microsoft Visual C# 2012, Fifth Edition

Writing a C# Program that Produces Output (cont’d.) Access modifier – Defines the circumstances under which the method can be accessed – Public, private, protected, internal 11Microsoft Visual C# 2012, Fifth Edition

Writing a C# Program that Produces Output (cont’d.) Keywords – Predefined and reserved identifiers that have special meaning to the compiler The name of the method is Main() – Every application must have a Main() method – Classes with a Main() method are called application classes; others are non-application classes The method returns nothing as indicated by the keyword void 12Microsoft Visual C# 2012, Fifth Edition

Selecting Identifiers Requirements – Must begin with an underscore, an at sign or a letter Letters include foreign-alphabet letters – Can contain only letters, digits, underscores, and the at sign Not special characters such as #, $, or & – Cannot be a C# reserved keyword 13Microsoft Visual C# 2012, Fifth Edition

14Microsoft Visual C# 2012, Fifth Edition

Selecting Identifiers (cont’d.) 15Microsoft Visual C# 2012, Fifth Edition

Selecting Identifiers (cont’d.) 16Microsoft Visual C# 2012, Fifth Edition

Selecting Identifiers (cont’d.) 17Microsoft Visual C# 2012, Fifth Edition

Adding Program Comments Program comments – Nonexecuting statements that document a program Comment out – Turn a statement into a comment Types of comments in C# – Line comments – Block comments 18Microsoft Visual C# 2012, Fifth Edition

Adding Program Comments (cont’d.) 19Microsoft Visual C# 2012, Fifth Edition

Using the System Namespace 20Microsoft Visual C# 2012, Fifth Edition

Using the System Namespace (cont’d.) 21Microsoft Visual C# 2012, Fifth Edition

Compiling and Executing a C# Program Steps for viewing a program’s output – Compile source code into intermediate language (IL) – The C# just in time (JIT) compiler translates the intermediate code into executable statements You can use either of two ways to compile – The command line – The Integrated Development Environment (IDE) 22Microsoft Visual C# 2012, Fifth Edition

Compiling Code from the Command Prompt Example of an operating system error message – Command csc stands for “C Sharp compiler” – Location of csc.exe c:\Windows\Microsoft.NET\Framework\vX.X.XXX 23Microsoft Visual C# 2012, Fifth Edition

Compiling Code from the Command Prompt (cont’d.) Example of a command line generated error message – Program error messages start with the program name followed by the line number and position within the line of the error 24Microsoft Visual C# 2012, Fifth Edition

Compiling Code Using the Visual Studio IDE Advantages of using the Visual Studio IDE – Some of the code you need is already created for you— auto-complete – The code is displayed in color – Some syntax errors are caught as you type – You can double-click an error message and the cursor will move to the line of code that contains the error – Other debugging tools are available 25Microsoft Visual C# 2012, Fifth Edition

Compiling Code Using the Visual Studio IDE (cont’d.) 26Microsoft Visual C# 2012, Fifth Edition

Deciding Which Environment to Use Advantage of using the command line – Saves disk space Advantages of using the Visual Studio IDE – Automatic sentence completion – Words are displayed using different colors based on their category – The code automatically generated by the IDE is very helpful when writing a GUI 27Microsoft Visual C# 2012, Fifth Edition

You Do It (cont’d.) Compiling and Executing a Program Using the Visual Studio IDE Steps – Create a new project (console application) – Enter the project name – Write your program using the editor – To compile the program, click Build on the menu bar, and then click Build Solution As an alternative, you can press F6 – Click Debug on the menu bar and then click Start Without Debugging 28Microsoft Visual C# 2012, Fifth Edition

29Microsoft Visual C# 2012, Fifth Edition You Do It (cont’d.)

Compiling and Executing a Program Using the Visual Studio IDE (cont’d.) 30Microsoft Visual C# 2012, Fifth Edition

Adding Comments to a Program Line comment example // Filename Hello.cs // Written by // Written on Block comment example /* This program demonstrates the use of the WriteLine() method to print the message Hello, world! */ 31Microsoft Visual C# 2012, Fifth Edition You Do It (cont’d.)