Developer to developer

Note for Chapter 1.4 : [Convert Antar Types]

  • Widening conversion memungkinkan convert type selama masih memungkinkan. Seperti dari Double ke Int dan sebaliknya(jika Option Strict=Off).
  • Narrowing conversion mengkonversi type yang tidak dalam jangkauannya. Bisa menggunakan System.Convert (antar type yang meng-implement System.IConvertible), CBool, CInt, CStr, CType, DirectCast, dan TryCast.
  • Boxing mengkonversi value type ke reference type (Cth. dari Int ke String).
  • Unboxing kebalikan boxing. Yaitu konvert reference type ke value type (Cth. CType(o as Object, i as Int)).
  • Sebaiknya hindari boxing-unboxing. Gunakan generic, type-spesific, dan override shadow member ToString, Equals, dan GetHash.
  • Baru di .NET 2.0. Gunakan conversion operators di Structure menggunakan keyword Widening dan Narrowing.

Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s