1 st Semester 2005 1 Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.

Slides:



Advertisements
Similar presentations
Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
Advertisements

1 Demo Reading Assignments Important terms & concepts Fundamental Data Types Identifier Naming Arithmetic Operations Sample Programs CSE Lecture.
Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
1 9/20/06CS150 Introduction to Computer Science 1 Review: Exam 1.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
Hello, world! Dissect HelloWorld.java Compile it Run it.
Basic Elements of C++ Chapter 2.
Introduction to C++ Programming
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.
Thanachat Thanomkulabut
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Introduction to C# Programming ณภัทร สักทอง Application Program Development.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
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.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
CH2 – Using Data. Constant Something which cannot be changed Data Type Format and size of a data item Intrinsic Data Types Pg. 47 – Table 2-1 Basic ones.
Chapter 2: Using Data.
Computer Programming TCP1224 Chapter 4 Variables, Constants, and Arithmetic Operators.
Chapter 2 Elementary Programming
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
C++ Programming: Basic Elements of C++.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Programming Fundamental Slides1 Data Types, Identifiers, and Expressions Topics to cover here: Data types Variables and Identifiers Arithmetic and Logical.
1 st Semester Module3 Condition Statement อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
CSC 107 – Programming For Science. The Week’s Goal.
C# Basic Concept Thanachat Thanomkulabut. Naming Rules  Letters, digits and underscores(_)  First character  letter or _  Up to 63 characters long.
1 st semester Basic Pascal Elements อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Input & Output Statement
VARIABLES AND DATA TYPES Chapter2:part1 1. Objectives: By the end of this section you should: Understand what the variables are and why they are used.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
C# Programming: Basic Concept Part 2 Computer and Programming (204111)
Lecture 5 Computer programming -1-. Input \ Output statement 1- Input (cin) : Use to input data from keyboard. Example : cin >> age; 2- Output (cout):
1 nd Semester Module2 C# Basic Concept Thanawin Rakthanmanon Computer Engineering Department Kasetsart University, Bangkok.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
1 st Semester Module3 Condition Statement อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
1 st Semester Module 7 Arrays อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering Department.
A Sample Program #include using namespace std; int main(void) { cout
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
1Object-Oriented Program Development Using C++ Built-in Data Types Data type –Range of values –Set of operations on those values Literal: refers to acceptable.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
1 nd Semester Module6 Review Thanawin Rakthanmanon Create by: Aphirak Jansang Computer Engineering Department Kasetsart.
Bill Tucker Austin Community College COSC 1315
Chapter Topics The Basics of a C++ Program Data Types
Elementary Programming
BASIC ELEMENTS OF A COMPUTER PROGRAM
Basic Elements of C++.
Data Types, Identifiers, and Expressions
Multiple variables can be created in one declaration
Computing with C# and the .NET Framework
Basic Elements of C++ Chapter 2.
Data Types, Identifiers, and Expressions
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
C# Programming.
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
Primitive Types and Expressions
Variables and Constants
Presentation transcript:

1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering Department Kasetsart University, Bangkok THAILAND

1 st Semester Outline  C# Overview  Variable and Constant  Expression  Statement

1 st Semester C# Program Overview  C# is an object-oriented programming language. class.  Everything must be in some class.  A program is a set of class declarations. แดง ขาว ด่าง โฮ่ง สุนัข class C# Overview

1 st Semester Very simple C# program example Starting Point C# Overview

1 st Semester Simple C# program structure Your Class Name Your declaration part Your statements Your Namespace Name C# Overview

1 st Semester C# Keywords Example Any keywords? C# Overview

1 st Semester More C# Keywords Example C# Overview

1 st Semester What is Objects? In computer languages “an object is called class” Object = Properties + Methods C# Overview

1 st Semester Example: Class declaration  Class Car class car { }  Class Human class human { { static void main() } } C# Overview

1 st Semester What is Namespace? Section of code specific name “Section of code that is identified by a specific name” Namespace example1 class Human class Car C# Overview Namespace example2 class Car

1 st Semester Example: namespace declaration  Namespace example1 namespace example1 { }  Namespace example2 + Class car namespace example2 { class car { } } C# Overview

1 st Semester Naming Guidelines  Letters, digits, underscores(_)  First character  letter  Can be long (63 char)  Reserved words (keywords) are not allowed *** Case Sensitive *** Example KU56 ≠ kU56 ≠ku56 KU56 ≠ kU56 ≠ ku56 C# Overview

1 st Semester Built-in Namespace: System Console Console class can be used for Displaying Displaying information on the screenSystem.Console.Write(”HelloWorld!”);System.Console.WriteLine(”HelloWorld!”); Retrieving Retrieving information from the user String ch; ch = System.Console.Readline(); C# Overview

1 st Semester Example: Console class C# Overview

1 st Semester Summary C# Program Overview  Namespace Class  Main() C# Overview

1 st Semester Practice: Try it by yourself  Declare the following class/namespace in C# syntax Class Movie Class HelloWorld Namespace KU65  Class Man  Class Woman C# Overview

1 st Semester Reference Problem  Calculate AREA of Rectangle!!! Width High AREA = Width x High C# Overview

1 st Semester Level1: Reference Problem C# Overview

1 st Semester Short break – 8 Minutes

1 st Semester Outline  C# Overview  Variable and Constant  Expression  Statement

1 st Semester Basic uses Declaration Part  Variable  Constant Variable & Constant

1 st Semester What is Variable? Variables are used to store “data.” “They must be declared before used” Variable & Constant

1 st Semester C# Declaration Location Declaration Part Here Variable & Constant

1 st Semester C# Variable Declaration  Syntax: ;  Example:  We can also assign its initial value. E.g., int radius; double area; int a,b,c; bool isokay; int k = 200; bool done = false; Variable & Constant

1 st Semester C# Basic Data Type  int Integer ( to )  double Floating-point ( )  bool Boolean values, true and false  char a Unicode character (’A’ ’B’)  string string of Unicode characters (”StarsIII”) Variable & Constant

1 st Semester Basic uses Declaration Part  Variable  Constant Variable & Constant

1 st Semester C# Constant Declaration  Syntax: const = ;  Example: const int radius = 15; const double area=1.5; const bool isokay=true; const string movie=”StarWarIII”; Variable & Constant

1 st Semester Example: Variable Declaration Variable & Constant

1 st Semester Level2: Reference Problem Variable & Constant

1 st Semester Short break – 5 Minutes

1 st Semester Outline  C# Overview  Variable and Constant  Expression  Statement

1 st Semester Expression in C#  Arithmetic Expression  Boolean ExpressionExpression

1 st Semester Arithmetic Expression  Operators + - * / % (remainder after division)  Example  / 2  % 2  % 2.2  0.6Expression

1 st Semester Precedence rules for Arithmetic Operators 1.( ) parentheses 2.*, /, % 3.+ – 4.If equal precedence, left to right Example int Width,High; Width=10*5+(16 * 12)/5; High= (16+5)+20%2;

1 st Semester Expression in C#  Arithmetic Expression  Boolean ExpressionExpression

1 st Semester Boolean Expression  Operators Comparison =  Equal = !=  Not equal != <  Less < >  Greater > <=  Less than or equal to <= >=  Greater than or equal to >= Boolean &&  And && ||  Or ||Expression

1 st Semester Short break – 5 Minutes

1 st Semester Outline  C# Overview  Variable and Constant  Expression  Statement

1 st Semester C# Statement LocationStatementsHereStatement

1 st Semester C# Statement Types  Assignment Statement  Input Statement  Output StatementStatement

1 st Semester Assignment Statement "put"  To "put" a value in the memory space allocated to a variable equal sign (=)  Use the equal sign (=) when making assignments.  Syntax: = ; = ; int Width,High; Width=10;High=5; int Width = 10; int High = 5; Statement

1 st Semester Example: Assignment StatementStatement

1 st Semester C# Statement Types  Assignment Statement  Input Statement  Output StatementStatement

1 st Semester Input Statement  Console.ReadLine()  Return string Use to get the input from user  Convert string to other data type int.Parse() Convert string to integer double.Parse() Convert string to double Example string yourname; yourname = Console.ReadLine(); Statement

1 st Semester Example: Input Statement Ex1: string myname; myname = Console.ReadLine(); Ex2: int Width,High; string temp1; temp1 = Console.ReadLine(); Width = int.Parse(temp1); temp1 = Console.ReadLine(); Width = int.Parse(temp1); Statement

1 st Semester Level3: Reference Problem Statement

1 st Semester C# Statement Types  Assignment Statement  Input Statement  Output StatementStatement

1 st Semester Output Statement  Console.WriteLine(VariableName)  Display variable value in some position of string  Output Formatting Example1 Console.WriteLine(”Hello {0}, {1}”, ps0, ps1); Example2 double salary=12000; Console.WriteLine("My salary is {0:f}.", salary); More information about formatting * Statement

1 st Semester Level4: Reference Problem Statement

1 st Semester Summary  C# Overview  Variable and Constant  Expression  StatementSummary