You are on page 1of 12

C# Fundamental

Chapter 2:

C# Basic

Agenda
Memulai C#

Language Style
Kompilasi

Struktur Program C#
Namespace
Variable

Basic I/O
Demo

Memulai C#
Baca: C-Sharp! Bukan C-Cresc

A new object oriented language


Syntax based on C

Similar to C++ and Java

Bahasa pemrograman yang didesain secara


khusus untuk lingkungan .NET Framework.
Chief Architect / Language Designer:
Anders Hejlsberg.

Language Style
Syntax based on C/C++
Case-sensitive
White space means nothing
Semicolons (;) to terminate statements
Code blocks use curly braces ({})
Object oriented, code is structured using
the class keyword

Kompilasi
Compiler terpisah dengan IDE Visual Studio
.NET
Auto Compiled dengan Visual Studio.NET
Manual Compilation dengan csc.exe
(CSharp Compiler)

csc.exe terdapat di dalam .NET Framework


SDK

Struktur Program C#
Namespaces

Terdiri dari type atau namespace yang lain

Sebuah namespace merepresentasikan sekumpulan


types secara logical

Type declarations

Classes, structs, interfaces, enums, and delegates

Members

Constants, fields, methods, properties, indexers, events,


operators, constructors, destructors.

Main Method

Entry point dari program yang akan dijalankan pertama


kali.

Namespace
Access Namespace

Using

Variabel
Tempat penyimpanan data sementara di
memori
Single Declaration :
string strNama;

string strNama = belajar C#;

Multiple Declaration :
int intUmur, intJumlah;

int intUmur, intJumlah = 0;

Variable Scope
Namespace / Class Level Variable
Procedure Level Variable
Block Level Variable

Namespace

Module

Procedure

Block

Komentar pada C#
Bagian comment tidak akan disertakan dalam
proses kompilasi.
Komentar pada 1 baris

Menggunakan simbol //

Cth; //int x = 10; ini tidak akan di-compile

Komentar pada 1 atau beberapa baris


Menggunakan simbol /* komentar */
Cth:

/*int a = 10;

a = a + 2; */

Basic I/O

Input

Output

Komentar pada C#
Demo:
Membuat Program C# pertama
dengan Notepad dan CSC

You might also like