1 Introduction to C# Programming Console applications No visual components Only text output Two types MS-DOS prompt - Used in Windows 95/98/ME Command.

Slides:



Advertisements
Similar presentations
Pemrograman VisualMinggu …2… Page 1 MINGGU Ke Dua Pemrograman Visual Pokok Bahasan: Console Application Tujuan Instruksional Khusus: Mahasiswa dapat menjelaskan.
Advertisements

 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Chapter 2 - Introduction to Java Applications
 2006 Pearson Education, Inc. All rights reserved Introduction to C# Applications.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 Introduction to Java Programming Lecture 4 Using JOptionPane Spring 2008.
CMT Programming Software Applications
 2002 Prentice Hall. All rights reserved. 1 Outline 3.1Introduction 3.2Simple Program: Printing a Line of Text 3.3Another Simple Program: Adding Integers.
School of Computing Science CMT1000 Ed Currie © Middlesex University Lecture 4: 1 CMT1000: Introduction to Programming Ed Currie Lecture 5a: Input and.
Repeating Instructions
Chapter 2 - Introduction to Java Applications
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
Beginning Programming with the Visual Studio.NET Environment.
An Introduction to C# and the .NET Framework
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
 2002 Prentice Hall. All rights reserved. 1 Lecture 1 Consolidation of first year work (part 1) Read all the chapters on your own Slides highlight important.
 2001 Prentice Hall, Inc. All rights reserved. 1 Introduction to C# Programming Part I.
Chapter 3 – Introduction to Visual Basic Programming
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A First Program in Java: Printing.
Jozef Goetz,  2009 Pearson Education, Inc. All rights reserved.  2002 Prentice Hall. All rights reserved. expanded by J. Goetz, 2012.
Advanced Programming LOOP.
C# B 1 CSC 298 Writing a C# application. C# B 2 A first C# application // Display Hello, world on the screen public class HelloWorld { public static void.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
1 Introduction to C# Programming Console applications No visual components Only text output Two types MS-DOS prompt - Used in Windows 95/98/ME Command.
Programming in C#. I. Introduction C# (or C-Sharp) is a programming language. C# is used to write software that runs on the.NET Framework. Although C#
 Simple C# program  Console applications input and output text in a console window, which in Windows XP and Windows Vista is known as the Command Prompt.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Introduction to Visual Basic Programming Introduction to Visual Basic Programming Ch3 – Deitel’s Book.
Introduction to Windows Programming
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
1 COMP 241: Object-Oriented Programming with Java Fall 2004 Lecture 1 September 27, 2004 Serdar Taşıran.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Introduction to Visual Basic Programming Chapter 3 – Introduction to Visual Basic Programming.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Dialog Boxes.
Advanced Programming LOOP. 2 while Repetition Structure Repetition Structure –An action is to be repeated Continues while statement is true Ends when.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
JavaScript 1 COE 201- Computer Proficiency. Introduction JavaScript scripting language ▫Originally created by Netscape ▫Facilitates disciplined approach.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A First Program in Java: Printing.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A First Program in Java: Printing.
Lecture 02 Dr. Eng. Ibrahim El-Nahry Methods. 2 Learning Objectives Class Definition includes both methods and data properties Method Definition and Declaration.
 2007 Pearson Education, Inc. All rights reserved Introduction to Visual Basic Programming.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A First Program in Java: Printing a Line of Text 2.2.1Compiling and Executing.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
2.5 Another Java Application: Adding Integers
Chapter 2 - Introduction to Java Applications
Chapter 7 - JavaScript: Introduction to Scripting
Advanced Programming Lecture 02: Introduction to C# Apps
JavaScript: Introduction to Scripting
Chapter 2 - Introduction to Java Applications
Chapter 2 - Introduction to Java Applications
Chapter 3 – Introduction to C# Programming
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 2 - Introduction to Java Applications
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Presentation transcript:

1 Introduction to C# Programming Console applications No visual components Only text output Two types MS-DOS prompt - Used in Windows 95/98/ME Command prompt - Used in windows 2000/NT/XP

2 Namespaces Group related C# features into a categories Contain code that can be reused.NET framework library contains many namespaces Must be referenced in order to be used Example: Console feature is in namespace System

3 Methods Building blocks of C# programs Every program is a class! The Main method Each console or windows application must have exactly one

4 Simple Program: Printing a Line of Text Visual Studio.NET-generated console application. Rename Complete the code

1 // Welcome1.cs 2 // A first console program in C#. 3 4 using System; 5 6 class Welcome1 7 { 8 static void Main( string[] args ) 9 { 10 Console.WriteLine( "Welcome to C# Programming!" ); 11 } 12 }

6 Simple Program: Output Execution of the Welcome1 program.

Welcome2.cs 1 // Welcome2.cs 2 // Printing a line with multiple statements. 3 4 using System; 5 6 class Welcome2 7 { 8 static void Main( string[] args ) 9 { 10 Console.Write( "Welcome to " ); 11 Console.WriteLine( "C# Programming!" ); 12 } 13 }

8 Some common escape sequences

9 Displaying output With C#  Windows applications Forms with several output types Contain Graphical User Interfaces (GUIs) Graphical User Interface GUIs are used to make it easier to get data from the user as well as display data to the user Message boxes Within the System.Windows.Forms namespace Used to prompt or display information to the user

Welcome4.cs 1 // Welcome4.cs 2 // Printing multiple lines in a dialog Box. 3 4 using System; 5 using System.Windows.Forms; 6 7 class Welcome4 8 { 9 static void Main( string[] args ) 10 { 11 MessageBox.Show( "Welcome\nto\nC#\nprogramming!" ); 12 } 13 } The System.Windows.Forms namespace allows the programmer to use the MessageBox class. This will display the contents in a message box as opposed to in the console window.

11 Adding a reference to an assembly in Visual Studio.NET Add Reference dialogue

12 Adding a reference to an assembly in Visual Studio.NET References folder Solution Explorer System.Windows.Forms reference

13 Dialog displayed by calling MessageBox.Show. OK button allows the user to dismiss the dialog. Dialog is automatically sized to accommodate its contents. Mouse cursor Close box

14 Getting input Primitive data types built into C# string, int, double, char, long …15 types Console.ReadLine() Used to get a value from the user input Int32.Parse() Used to convert a string argument to an integer Allows math to be performed once the string is converted

1 // Addition.cs 2 // An addition program. 3 4 using System; 5 6 class Addition 7 { 8 static void Main( string[] args ) 9 { 10 string firstNumber, // first string entered by user 11 secondNumber; // second string entered by user int number1, // first number to add 14 number2, // second number to add 15 sum; // sum of number1 and number // prompt for and read first number from user as string 18 Console.Write( "Please enter the first integer: " ); 19 firstNumber = Console.ReadLine();

21 // read second number from user as string 22 Console.Write( "\nPlease enter the second integer: " ); 23 secondNumber = Console.ReadLine(); // convert numbers from type string to type int 26 number1 = Int32.Parse( firstNumber ); 27 number2 = Int32.Parse( secondNumber ); // add numbers 30 sum = number1 + number2; // display results 33 Console.WriteLine( "\nThe sum is {0}.", sum ); } // end method Main } // end class Addition

17 Combining steps 21 // read second number from user as string 22 Console.Write( "\nPlease enter the second integer: " ); 23 number2 = Int32.Parse( Console.ReadLine() );

18 Should know! Memory Concepts Arithmetic Decision Making: Equality and Relational Operators