1 / 10

Visual Basic.NET – Tipe Data

Visual Basic.NET – Tipe Data. Rully Yulian MF MCAD,MCPD,MCT,MVP VB.NET Independent IT Trainer - Application Developer http://www.yulianmf.com rully@yulianmf.com. Overview. Tipe Data Common Type System (CTS) Enumerasi Konversi Tipe Data Boxing And Unboxing. Tipe Data .

xuxa
Télécharger la présentation

Visual Basic.NET – Tipe Data

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. Visual Basic.NET – Tipe Data Rully Yulian MF MCAD,MCPD,MCT,MVP VB.NET Independent IT Trainer - Application Developer http://www.yulianmf.com rully@yulianmf.com

  2. Overview • Tipe Data • Common Type System (CTS) • Enumerasi • Konversi Tipe Data • Boxing And Unboxing

  3. Tipe Data • Terdapat dua jenis tipe data. Secara umum dapat dibagi ke dalam kelompok • Value Type • Reference Type

  4. Tipe Data (Value Type) • Value Type • Dialokasikan di Stack Memori • Not Garbage Collected • Primitive Data Type : Integer, Boolean, Double, DateTime, Structure, Enumerasi • Diturunkan dari System.ValueType namespace • Memiliki copy data masing-masing • Perubahan satu nilai tidak mempengaruhi nilai yang lainnya.

  5. Tipe Data (Reference Type) • Reference Type • Dialokasikan di Heap Memory • Diturunkan dari System.Object namespace • Garbage Collected • Class, Delegate, Array, String • Satu object dapat di referensi oleh lebih dari satu variabel • Perubahan nilai pada object referensi yang sama akan mempengaruhi nilai lainnya.

  6. Local Type Inference (VB 9.0) • Deklarasi variabel tanpa mendefinisikan tipe data • Hanya berlaku untuk procedure scope • Nilai variabel harus langsung di inisialisasi • Strongly Typed <> Object Data Type • Option Infer = On

  7. Common Type System • Digunakan oleh semua .NET Language • Bagian dari spesifikasi Common Language Infrastructure (CLI) • C# string = VB String • VB Integer = CTS System.Int32 • VB DateTime = CTS System.DateTime

  8. Enumerasi • Kumpulan konstanta yang memiliki nilai tetap • Memudahkan pembacaan kode • Digunakan sebagai input pilihan • Menggunakan simbol (nama) daripada nilai numeriknya • Default tipe data yang digunakan yaitu Integer • Nilai default untuk elemen pertama = 0, kedua = 1,…dst. Nilai default tersebut dapat diubah dan tidak harus terurut.

  9. Konversi Tipe Data • Merubah satu tipe data ke tipe data lain • Terdapat dua jenis konversi tipe data : • Implicit : • Otomatis di konversi • Memungkinkan terjadinya run time error • Narrowing Conversion = OverflowException • Widening Conversion = No Problem! • Set Option Strict = On (Default = Off) • Explicit • Menggunakan fungsi konversi • Ctype, DirectCast, TryCast, Cint, Cbool, CStr • Boxing and Unboxing

  10. Boxing and Unboxing • Boxing merupakan proses konversi tipe data dari Value Type keReference Type • Unboxing merupakan proses konversi tipe data dari Reference Type keValue Type • Untuk melakukan Boxing dibutuhkan konversiImplicit atau Explicit (optional) • Untuk melakukan Unboxing dibutuhkan konversiExplicit • Menyebabkan Performance Degradation

More Related