1 / 16

CLASS in C#

CLASS in C#. BUDI DARMA SETIAWAN. PBO ( Pemrograman Berorientasi Objek ). OOP (Object Oriented programming) Menggambarkan sesuatu di dalam program sebagai sebuah objek Contoh objek : orang , kursi , meja , dll Ciri – ciri objek adalah dapat dinyatakan dengan kata benda. Objek.

clem
Télécharger la présentation

CLASS in C#

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CLASS in C# BUDI DARMA SETIAWAN

  2. PBO (PemrogramanBerorientasiObjek) • OOP (Object Oriented programming) • Menggambarkansesuatudidalam program sebagaisebuahobjek • Contohobjek: orang, kursi, meja, dll • Ciri – ciriobjekadalahdapatdinyatakandengankatabenda

  3. Objek • Objekmemilikikarakteristikberupasifat/ciridanprilaku • Sifat/ciri = varibel • Prilaku = fugsi / prosedur

  4. Class • Kelasmemberikantemplate (cetakan) karakteristikdarisebuahobjek • Contohnya :

  5. Objekdan Class • Objekadalahinstansiasidarikelas • Contoh: • Objekmanajeradalahinstansiasidarikelaspegawai • Objeksekretarisjugaadalahinstansiasidarikelaspegawai • Artinya???

  6. Objekdan Class • Manager memilikkarakteristik yang samadengan class pegawai • Dan Sekretarisjugamemilikikarakteristik yang samadenganclaspegawai

  7. Field • Tempatmenyimpan data • Berupatipe data primitif • Integer (int) • Double • Character (char) • String/string • Enumeration (enum)

  8. Method • Bisadikatakanprilakuobjek • BerbentukFungsiatauProsedur • Contoh: • naikPangkat(); • mengajukanCuti(); • setNama(); • getNama();

  9. Konstruktor • Method yang otomatisdijalankansaatobjekdibuat (saatprosesinstansiasi) • Namakonstruktorsamadengannamakelas • Sebuahkelasbisamemilikilebihdarisatukonstruktor (costructor overloading)

  10. Access Modifier • Private hanyabisadiaksesolehkelasitusendiri • Public bisadiaksesolehkelas lain • Protected hayabisadiaksesolehkelasitusendiribesertaturunannya

  11. AturanPenulisan • Kelas : • Biasanyadiawalidenganhurufkapital • Jikaterdiridari 2 kataataulebih, Setiaphurufawaldiawalidenganhurufkapital • Contoh: class Manusia, class OrangHutan • Method: • Peulisandiawalidenganhurufkecil • Kata ke2 danseterusnyadiawalidenganhurufkapital • Contoh: void naikGaji();

  12. AturanPenulisan • Variabel • Menggunakanhurufkecilsemua

  13. Question??

  14. Static • Static classes and class members are used to create data and functions that can be accessed without creating an instance of the class • A class can be declared static, indicating that it contains only static members • Use a static class to contain methods that are not associated with a particular object.

  15. Static • For example, it is a common requirement to create a set of methods that do not act on instance data and are not associated to a specific object in your code. • You could use a static class to hold those methods. • The main features of a static class are: • They only contain static members. • They cannot be instantiated. • They are sealed. • They cannot contain Instance Constructors (C# Programming Guide).

  16. TerimaKasih Wassalamualaikum

More Related