Matakuliah Tahun : M0874 – Programming II : 2010 Introduction to C# Programming Session 02 Outline Materi •Introduction •Simple Program: Printing a Line of Text •Memory Concepts •Arithmetic •Equality and Relational Operators Bina Nusantara University 3 Introduction •With C#, a program can be created with multiple types of output (windows, dialogs and so forth). •These programs are called Windows applications and provide graphical user interfaces. •Console applications – applications that contain only text output. Bina Nusantara University 4 Simple Program: Printing a Line of Text 5 Bina Nusantara University Simple Program: Printing a Line of Text •Output: •Line begins with //, indicating that the remainder of the line is a comment. •Programmers insert comments to document and improve readability of their code. Bina Nusantara University 6 Simple Program: Printing a Line of Text •A multiple-line comment begins with delimeter /* and ends with delimeter */, such as: •/*This is a multiple-line comment. It can be split over many lines*/ Bina Nusantara University 7 Memory Concepts •Variable names actually correspond to locations in the computer’s memory. •Every variable has a name, a type, a size, and a value. •Example: number1 = Int32.Parse( firstNumber ); number2 = Int32.Parse( secondNumber ); sum = number1 + number2; Bina Nusantara University 8 Arithmetic Bina Nusantara University 9 Precedence of arithmetic operators Bina Nusantara University 10 Equality and Relational Operators Standard algebraic C# equality or equality operator or relational relational operator operator Example of C# condition Meaning of C# condition Equality operators == == x == y x is equal to y ‡ != x != y x is not equal to y > > x>y x is greater than y < < x<y x is less than y >= >= x >= y x is greater than or equal to y <= <= x <= y x is less than or equal to y Relational operators 11 Bina Nusantara University References •http://books.google.co.id/books?id=8R451rZJ5o0C &printsec=frontcover&dq=c%23&cd=2#v=onepage& q=&f=false •http://devhood.com/training_modules/dista/Intro.NET/Intro.NET_pres_files/v3_document.htm Bina Nusantara University 12