Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Komentar dokumentasi adalah komentar yang diformat khusus di sumber yang dapat dianalisis untuk menghasilkan dokumentasi tentang kode yang dilampirkan. Format dasar untuk komentar dokumentasi adalah XML. Saat mengkompilasi kode dengan komentar dokumentasi, pengkompilasi dapat secara opsional memancarkan file XML yang mewakili jumlah total komentar dokumentasi di sumber. File XML ini kemudian dapat digunakan oleh alat lain untuk menghasilkan dokumentasi cetak atau online.
Bab ini menjelaskan komentar dokumen dan tag XML yang direkomendasikan untuk digunakan dengan komentar dokumen.
Format Komentar Dokumentasi
Komentar dokumen adalah komentar khusus yang dimulai dengan ''', tiga tanda kutip tunggal. Mereka harus segera mendahului jenis (seperti kelas, delegasi, atau antarmuka) atau anggota jenis (seperti bidang, peristiwa, properti, atau metode) yang mereka dokumentasikan. Komentar dokumen pada deklarasi metode parsial akan digantikan oleh komentar dokumen pada metode yang memasok isinya, jika ada. Semua komentar dokumen yang berdekatan ditambahkan bersama-sama untuk menghasilkan satu komentar dokumen. Jika ada karakter spasi kosong yang mengikuti ''' karakter, maka karakter spasi putih tersebut tidak disertakan dalam perangkaian. Contohnya:
''' <remarks>
''' Class <c>Point</c> models a point in a two-dimensional plane.
''' </remarks>
Public Class Point
''' <remarks>
''' Method <c>Draw</c> renders the point.
''' </remarks>
Sub Draw()
End Sub
End Class
Komentar dokumentasi harus dibentuk dengan baik XML menurut https://www.w3.org/TR/REC-xml. Jika XML tidak terbentuk dengan baik, peringatan dibuat dan file dokumentasi akan berisi komentar yang mengatakan bahwa terjadi kesalahan.
Meskipun pengembang bebas membuat sekumpulan tag mereka sendiri, set yang direkomendasikan ditentukan di bagian berikutnya. Beberapa tag yang direkomendasikan memiliki arti khusus:
Tag
<param>digunakan untuk menjelaskan parameter. Parameter yang<param>ditentukan oleh tag harus ada dan semua parameter anggota jenis harus dijelaskan dalam komentar dokumentasi. Jika salah satu kondisi tidak benar, pengkompilasi mengeluarkan peringatan.Atribut
crefdapat dilampirkan ke tag apa pun untuk memberikan referensi ke elemen kode. Elemen kode harus ada; pada waktu kompilasi pengkompilasi menggantikan nama dengan string ID yang mewakili anggota. Jika elemen kode tidak ada, pengkompilasi mengeluarkan peringatan. Saat mencari nama yang dijelaskan dalamcrefatribut, pengkompilasi menghormatiImportspernyataan yang muncul dalam file sumber yang berisi.Tag
<summary>dimaksudkan untuk digunakan oleh penampil dokumentasi untuk menampilkan informasi tambahan tentang jenis atau anggota.
Perhatikan bahwa file dokumentasi tidak memberikan informasi lengkap tentang jenis dan anggota, hanya apa yang terkandung dalam komentar dokumen. Untuk mendapatkan informasi selengkapnya tentang jenis atau anggota, file dokumentasi harus digunakan bersama dengan pantulan pada jenis atau anggota yang sebenarnya.
Tag yang direkomendasikan
Generator dokumentasi harus menerima dan memproses tag apa pun yang valid sesuai dengan aturan XML. Tag berikut menyediakan fungsionalitas yang umum digunakan dalam dokumentasi pengguna:
<c> Mengatur teks dalam font seperti kode
<code> Mengatur satu atau beberapa baris kode sumber atau output program dalam font seperti kode
<example> Menunjukkan contoh
<exception> Mengidentifikasi pengecualian yang dapat dilemparkan metode
<include> Menyertakan dokumen XML eksternal
<list> Membuat daftar atau tabel
<para> Mengizinkan struktur ditambahkan ke teks
<param> Menjelaskan parameter untuk metode atau konstruktor
<paramref> Mengidentifikasi bahwa kata adalah nama parameter
<permission> Mencakup aksesibilitas keamanan anggota
<remarks> Menjelaskan jenis
<returns> Menjelaskan nilai pengembalian metode
<see> Menentukan tautan
<seealso> Menghasilkan entri Lihat Juga
<summary> Menjelaskan anggota tipe
<typeparam> Menjelaskan parameter jenis
<value> Menjelaskan properti
<c>
Tag ini menentukan bahwa fragmen teks dalam deskripsi harus menggunakan font seperti yang digunakan untuk blok kode. (Untuk baris kode aktual, gunakan <code>.)
Sintaks:
<c>text to be set like code</c>
Example:
''' <remarks>
''' Class <c>Point</c> models a point in a two-dimensional plane.
''' </remarks>
Public Class Point
End Class
<kode>
Tag ini menentukan bahwa satu atau beberapa baris kode sumber atau output program harus menggunakan font lebar tetap. (Untuk fragmen kode kecil, gunakan <c>.)
Sintaks:
<code>source code or program output</code>
Example:
''' <summary>
''' This method changes the point's location by the given x- and
''' y-offsets.
''' <example>
''' For example:
''' <code>
''' Dim p As Point = New Point(3,5)
''' p.Translate(-1,3)
''' </code>
''' results in <c>p</c>'s having the value (2,8).
''' </example>
''' </summary>
Public Sub Translate(x As Integer, y As Integer)
Me.x += x
Me.y += y
End Sub
<contoh>
Tag ini memungkinkan contoh kode dalam komentar untuk menunjukkan bagaimana elemen dapat digunakan. Biasanya, ini akan melibatkan penggunaan tag <code> juga.
Sintaks:
<example>description</example>
Example:
Lihat <code> sebagai contoh.
<pengecualian>
Tag ini menyediakan cara untuk mendokumen pengecualian yang dapat dilemparkan metode.
Sintaks:
<exception cref="member">description</exception>
Example:
Public Module DataBaseOperations
''' <exception cref="MasterFileFormatCorruptException"></exception>
''' <exception cref="MasterFileLockedOpenException"></exception>
Public Sub ReadRecord(flag As Integer)
If Flag = 1 Then
Throw New MasterFileFormatCorruptException()
ElseIf Flag = 2 Then
Throw New MasterFileLockedOpenException()
End If
' ...
End Sub
End Module
<termasuk>
Tag ini digunakan untuk menyertakan informasi dari dokumen XML eksternal yang terbentuk dengan baik. Ekspresi XPath diterapkan ke dokumen XML untuk menentukan XML apa yang harus disertakan dari dokumen. Tag <include> kemudian diganti dengan XML yang dipilih dari dokumen eksternal.
Sintaks:
<include file="filename" path="xpath">
Example:
Jika kode sumber berisi deklarasi seperti berikut:
''' <include file="docs.xml" path="extra/class[@name="IntList"]/*" />
dan file eksternal docs.xml memiliki konten berikut
<?xml version="1.0"?>
<extra>
<class name="IntList">
<summary>
Contains a list of integers.
</summary>
</class>
<class name="StringList">
<summary>
Contains a list of strings.
</summary>
</class>
</extra>
maka dokumentasi yang sama akan dihasilkan sebagai jika kode sumber mengandung:
''' <summary>
''' Contains a list of integers.
''' </summary>
<daftar>
Tag ini digunakan untuk membuat daftar atau tabel item. Ini mungkin berisi <listheader> blok untuk menentukan baris judul tabel atau daftar definisi. (Saat menentukan tabel, hanya entri untuk istilah dalam judul yang perlu disediakan.)
Setiap item dalam daftar ditentukan dengan blok <item>. Saat membuat daftar definisi, istilah dan deskripsi harus ditentukan. Namun, untuk tabel, daftar berpoin, atau daftar bernomor, hanya deskripsi yang perlu ditentukan.
Sintaks:
<list type="bullet" | "number" | "table">
<listheader>
<term>term</term>
<description>description</description>
</listheader>
<item>
<term>term</term>
<description>description</description>
</item>
...
<item>
<term>term</term>
<description>description</description>
</item>
</list>
Example:
Public Class TestClass
''' <remarks>
''' Here is an example of a bulleted list:
''' <list type="bullet">
''' <item>
''' <description>Item 1.</description>
''' </item>
''' <item>
''' <description>Item 2.</description>
''' </item>
''' </list>
''' </remarks>
Public Shared Sub Main()
End Sub
End Class
<p>ara
Tag ini untuk digunakan di dalam tag lain, seperti <remarks> atau <returns>, dan mengizinkan struktur ditambahkan ke teks.
Sintaks:
<para>content</para>
Example:
''' <summary>
''' This is the entry point of the Point class testing program.
''' <para>This program tests each method and operator, and
''' is intended to be run after any non-trvial maintenance has
''' been performed on the Point class.</para>
''' </summary>
Public Shared Sub Main()
End Sub
<Parameter>
Tag ini menjelaskan parameter untuk metode, konstruktor, atau properti terindeks.
Sintaks:
<param name="name">description</param>
Example:
''' <summary>
''' This method changes the point's location to the given
''' coordinates.
''' </summary>
''' <param name="x"><c>x</c> is the new x-coordinate.</param>
''' <param name="y"><c>y</c> is the new y-coordinate.</param>
Public Sub Move(x As Integer, y As Integer)
Me.x = x
Me.y = y
End Sub
<paramref>
Tag ini menunjukkan bahwa kata adalah parameter. File dokumentasi dapat diproses untuk memformat parameter ini dengan beberapa cara yang berbeda.
Sintaks:
<paramref name="name"/>
Example:
''' <summary>
''' This constructor initializes the new Point to
''' (<paramref name="x"/>,<paramref name="y"/>).
''' </summary>
''' <param name="x"><c>x</c> is the new Point's x-coordinate.</param>
''' <param name="y"><c>y</c> is the new Point's y-coordinate.</param>
Public Sub New(x As Integer, y As Integer)
Me.x = x
Me.y = y
End Sub
<izin>
Tag ini mencakup aksesibilitas keamanan anggota
Sintaks:
<permission cref="member">description</permission>
Example:
''' <permission cref="System.Security.PermissionSet">Everyone can
''' access this method.</permission>
Public Shared Sub Test()
End Sub
<keterangan>
Tag ini menentukan informasi gambaran umum tentang jenis. (Gunakan <summary> untuk menjelaskan anggota jenis.)
Sintaks:
<remarks>description</remarks>
Example:
''' <remarks>
''' Class <c>Point</c> models a point in a two-dimensional plane.
''' </remarks>
Public Class Point
End Class
<pengembalian>
Tag ini menjelaskan nilai pengembalian metode.
Sintaks:
<returns>description</returns>
Example:
''' <summary>
''' Report a point's location as a string.
''' </summary>
''' <returns>
''' A string representing a point's location, in the form (x,y), without
''' any leading, training, or embedded whitespace.
''' </returns>
Public Overrides Function ToString() As String
Return "(" & x & "," & y & ")"
End Sub
<lihat>
Tag ini memungkinkan tautan ditentukan dalam teks. (Gunakan <seealso> untuk menunjukkan teks yang akan muncul di bagian Lihat Juga.)
Sintaks:
<see cref="member"/>
Example:
''' <summary>
''' This method changes the point's location to the given
''' coordinates.
''' </summary>
''' <see cref="Translate"/>
Public Sub Move(x As Integer, y As Integer)
Me.x = x
Me.y = y
End Sub
''' <summary>
''' This method changes the point's location by the given x- and
''' y-offsets.
''' </summary>
''' <see cref="Move"/>
Public Sub Translate(x As Integer, y As Integer)
Me.x += x
Me.y += y
End Sub
<lihat juga>
Tag ini menghasilkan entri untuk bagian Lihat Juga. (Gunakan <see> untuk menentukan tautan dari dalam teks.)
Sintaks:
<seealso cref="member"/>
Example:
''' <summary>
''' This method determines whether two Points have the same location.
''' </summary>
''' <seealso cref="operator=="/>
''' <seealso cref="operator!="/>
Public Overrides Function Equals(o As Object) As Boolean
' ...
End Function
<ringkasan>
Tag ini menjelaskan anggota jenis. (Gunakan <remarks> untuk menjelaskan jenis itu sendiri.)
Sintaks:
<summary>description</summary>
Example:
''' <summary>
''' This constructor initializes the new Point to (0,0).
''' </summary>
Public Sub New()
Me.New(0,0)
End Sub
<typeparam>
Tag ini menjelaskan parameter jenis.
Sintaks:
<typeparam name="name">description</typeparam>
Example:
''' <typeparam name="T">
''' The base item type. Must implement IComparable.
''' </typeparam>
Public Class ItemManager(Of T As IComparable)
End Class
<nilai>
Tag ini menjelaskan properti.
Sintaks:
<value>property description</value>
Example:
''' <value>
''' Property <c>X</c> represents the point's x-coordinate.
''' </value>
Public Property X() As Integer
Get
Return _x
End Get
Set (Value As Integer)
_x = Value
End Set
End Property
String ID
Saat membuat file dokumentasi, pengkompilasi menghasilkan string ID untuk setiap elemen dalam kode sumber yang ditandai dengan komentar dokumentasi yang mengidentifikasinya secara unik. String ID ini dapat digunakan oleh alat eksternal untuk mengidentifikasi elemen mana dalam rakitan yang dikompilasi sesuai dengan komentar dokumen.
String ID dihasilkan sebagai berikut:
Tidak ada spasi kosong dalam string.
Bagian pertama dari string mengidentifikasi jenis anggota yang didokumentasikan, melalui satu karakter diikuti oleh titik dua. Jenis anggota berikut didefinisikan, dengan karakter yang sesuai dalam tanda kurung setelahnya: peristiwa (E), bidang (F), metode termasuk konstruktor dan operator (M), namespace (N), properti (P) dan jenis (T). Tanda seru (!) menunjukkan kesalahan terjadi saat menghasilkan string ID, dan string lainnya memberikan informasi tentang kesalahan.
Bagian kedua dari string adalah nama elemen yang sepenuhnya memenuhi syarat, dimulai dari namespace global. Nama elemen, jenis penutupnya, dan namespace dipisahkan oleh titik. Jika nama item itu sendiri memiliki titik, item digantikan oleh tanda pagar (#). (Diasumsikan bahwa tidak ada elemen yang memiliki karakter ini dalam namanya.) Nama jenis dengan parameter jenis diakhir dengan backquote (') diikuti dengan angka yang mewakili jumlah parameter jenis pada jenis. Penting untuk diingat bahwa karena jenis berlapis memiliki akses ke parameter jenis jenis yang berisinya, jenis berlapis secara implisit berisi parameter jenis jenis yang berisi, dan jenis tersebut dihitung dalam total parameter jenisnya dalam kasus ini.
Untuk metode dan properti dengan argumen, daftar argumen ditempatkan setelahnya dalam tanda kurung. Untuk mereka yang tanpa argumen, tanda kurung dihilangkan. Argumen dipisahkan oleh koma. Pengodean setiap argumen sama dengan tanda tangan CLI, sebagai berikut: Argumen diwakili oleh nama yang sepenuhnya memenuhi syarat. Misalnya, Integer menjadi System.Int32, String menjadi System.String, Object menjadi System.Object, dan sebagainya. Argumen yang memiliki pengubah ByRef memiliki '@' mengikuti nama jenisnya. Argumen yang memiliki ByValpengubah , Optional atau ParamArray tidak memiliki notasi khusus. Argumen yang merupakan array diwakili sebagai [lowerbound:size, ..., lowerbound:size] di mana jumlah koma adalah peringkat - 1, dan batas dan ukuran yang lebih rendah dari setiap dimensi, jika diketahui, diwakili dalam desimal. Jika batas atau ukuran yang lebih rendah tidak ditentukan, maka akan dihilangkan. Jika batas dan ukuran yang lebih rendah untuk dimensi tertentu dihilangkan, ':' juga dihilangkan. Array array diwakili oleh satu "[]" per tingkat.
Contoh string ID
Contoh berikut masing-masing menunjukkan fragmen kode VB, bersama dengan string ID yang dihasilkan dari setiap elemen sumber yang mampu memiliki komentar dokumentasi:
Jenis diwakili menggunakan nama yang sepenuhnya memenuhi syarat.
Enum Color
Red
Blue
Green
End Enum
Namespace Acme
Interface IProcess
End Interface
Structure ValueType
...
End Structure
Class Widget
Public Class NestedClass
End Class
Public Interface IMenuItem
End Interface
Public Delegate Sub Del(i As Integer)
Public Enum Direction
North
South
East
West
End Enum
End Class
End Namespace
"T:Color"
"T:Acme.IProcess"
"T:Acme.ValueType"
"T:Acme.Widget"
"T:Acme.Widget.NestedClass"
"T:Acme.Widget.IMenuItem"
"T:Acme.Widget.Del"
"T:Acme.Widget.Direction"
Bidang diwakili oleh nama yang sepenuhnya memenuhi syarat.
Namespace Acme
Structure ValueType
Private total As Integer
End Structure
Class Widget
Public Class NestedClass
Private value As Integer
End Class
Private message As String
Private Shared defaultColor As Color
Private Const PI As Double = 3.14159
Protected ReadOnly monthlyAverage As Double
Private array1() As Long
Private array2(,) As Widget
End Class
End Namespace
"F:Acme.ValueType.total"
"F:Acme.Widget.NestedClass.value"
"F:Acme.Widget.message"
"F:Acme.Widget.defaultColor"
"F:Acme.Widget.PI"
"F:Acme.Widget.monthlyAverage"
"F:Acme.Widget.array1"
"F:Acme.Widget.array2"
Konstruktor.
Namespace Acme
Class Widget
Shared Sub New()
End Sub
Public Sub New()
End Sub
Public Sub New(s As String)
End Sub
End Class
End Namespace
"M:Acme.Widget.#cctor"
"M:Acme.Widget.#ctor"
"M:Acme.Widget.#ctor(System.String)"
Metode.
Namespace Acme
Structure ValueType
Public Sub M(i As Integer)
End Sub
End Structure
Class Widget
Public Class NestedClass
Public Sub M(i As Integer)
End Sub
End Class
Public Shared Sub M0()
End Sub
Public Sub M1(c As Char, ByRef f As Float, _
ByRef v As ValueType)
End Sub
Public Sub M2(x1() As Short, x2(,) As Integer, _
x3()() As Long)
End Sub
Public Sub M3(x3()() As Long, x4()(,,) As Widget)
End Sub
Public Sub M4(Optional i As Integer = 1)
Public Sub M5(ParamArray args() As Object)
End Sub
End Class
End Namespace
"M:Acme.ValueType.M(System.Int32)"
"M:Acme.Widget.NestedClass.M(System.Int32)"
"M:Acme.Widget.M0"
"M:Acme.Widget.M1(System.Char,System.Single@,Acme.ValueType@)"
"M:Acme.Widget.M2(System.Int16[],System.Int32[0:,0:],System.Int64[][])"
"M:Acme.Widget.M3(System.Int64[][],Acme.Widget[0:,0:,0:][])"
"M:Acme.Widget.M4(System.Int32)"
"M:Acme.Widget.M5(System.Object[])"
Properti.
Namespace Acme
Class Widget
Public Property Width() As Integer
Get
End Get
Set (Value As Integer)
End Set
End Property
Public Default Property Item(i As Integer) As Integer
Get
End Get
Set (Value As Integer)
End Set
End Property
Public Default Property Item(s As String, _
i As Integer) As Integer
Get
End Get
Set (Value As Integer)
End Set
End Property
End Class
End Namespace
"P:Acme.Widget.Width"
"P:Acme.Widget.Item(System.Int32)"
"P:Acme.Widget.Item(System.String,System.Int32)"
Peristiwa
Namespace Acme
Class Widget
Public Event AnEvent As EventHandler
Public Event AnotherEvent()
End Class
End Namespace
"E:Acme.Widget.AnEvent"
"E:Acme.Widget.AnotherEvent"
Operator.
Namespace Acme
Class Widget
Public Shared Operator +(x As Widget) As Widget
End Operator
Public Shared Operator +(x1 As Widget, x2 As Widget) As Widget
End Operator
End Class
End Namespace
"M:Acme.Widget.op_UnaryPlus(Acme.Widget)"
"M:Acme.Widget.op_Addition(Acme.Widget,Acme.Widget)"
Operator konversi memiliki trailing ~ diikuti dengan jenis pengembalian.
Namespace Acme
Class Widget
Public Shared Narrowing Operator CType(x As Widget) As _
Integer
End Operator
Public Shared Widening Operator CType(x As Widget) As Long
End Operator
End Class
End Namespace
"M:Acme.Widget.op_Explicit(Acme.Widget)~System.Int32"
"M:Acme.Widget.op_Implicit(Acme.Widget)~System.Int64"
Contoh komentar dokumentasi
Contoh berikut menunjukkan kode Point sumber kelas:
Namespace Graphics
''' <remarks>
''' Class <c>Point</c> models a point in a two-dimensional
''' plane.
''' </remarks>
Public Class Point
''' <summary>
''' Instance variable <c>x</c> represents the point's x-coordinate.
''' </summary>
Private _x As Integer
''' <summary>
''' Instance variable <c>y</c> represents the point's y-coordinate.
''' </summary>
Private _y As Integer
''' <value>
''' Property <c>X</c> represents the point's x-coordinate.
''' </value>
Public Property X() As Integer
Get
Return _x
End Get
Set(Value As Integer)
_x = Value
End Set
End Property
''' <value>
''' Property <c>Y</c> represents the point's y-coordinate.
''' </value>
Public Property Y() As Integer
Get
Return _y
End Get
Set(Value As Integer)
_y = Value
End Set
End Property
''' <summary>
''' This constructor initializes the new Point to (0,0).
''' </summary>
Public Sub New()
Me.New(0, 0)
End Sub
''' <summary>
''' This constructor initializes the new Point to
''' (<paramref name="x"/>,<paramref name="y"/>).
''' </summary>
''' <param name="x"><c>x</c> is the new Point's
''' x-coordinate.</param>
''' <param name="y"><c>y</c> is the new Point's
''' y-coordinate.</param>
Public Sub New(x As Integer, y As Integer)
Me.X = x
Me.Y = y
End Sub
''' <summary>
''' This method changes the point's location to the given
''' coordinates.
''' </summary>
''' <param name="x"><c>x</c> is the new x-coordinate.</param>
''' <param name="y"><c>y</c> is the new y-coordinate.</param>
''' <see cref="Translate"/>
Public Sub Move(x As Integer, y As Integer)
Me.X = x
Me.Y = y
End Sub
''' <summary>
''' This method changes the point's location by the given x- and
''' y-offsets.
''' <example>
''' For example:
''' <code>
''' Dim p As Point = New Point(3, 5)
''' p.Translate(-1, 3)
''' </code>
''' results in <c>p</c>'s having the value (2,8).
''' </example>
''' </summary>
''' <param name="x"><c>x</c> is the relative x-offset.</param>
''' <param name="y"><c>y</c> is the relative y-offset.</param>
''' <see cref="Move"/>
Public Sub Translate(x As Integer, y As Integer)
Me.X += x
Me.Y += y
End Sub
''' <summary>
''' This method determines whether two Points have the same
''' location.
''' </summary>
''' <param name="o"><c>o</c> is the object to be compared to the
''' current object.</param>
''' <returns>
''' True if the Points have the same location and they have the
''' exact same type; otherwise, false.
''' </returns>
''' <seealso cref="Operator op_Equality"/>
''' <seealso cref="Operator op_Inequality"/>
Public Overrides Function Equals(o As Object) As Boolean
If o Is Nothing Then
Return False
End If
If o Is Me Then
Return True
End If
If Me.GetType() Is o.GetType() Then
Dim p As Point = CType(o, Point)
Return (X = p.X) AndAlso (Y = p.Y)
End If
Return False
End Function
''' <summary>
''' Report a point's location as a string.
''' </summary>
''' <returns>
''' A string representing a point's location, in the form
''' (x,y), without any leading, training, or embedded whitespace.
''' </returns>
Public Overrides Function ToString() As String
Return "(" & X & "," & Y & ")"
End Function
''' <summary>
''' This operator determines whether two Points have the
''' same location.
''' </summary>
''' <param name="p1"><c>p1</c> is the first Point to be compared.
''' </param>
''' <param name="p2"><c>p2</c> is the second Point to be compared.
''' </param>
''' <returns>
''' True if the Points have the same location and they
''' have the exact same type; otherwise, false.
''' </returns>
''' <seealso cref="Equals"/>
''' <seealso cref="op_Inequality"/>
Public Shared Operator =(p1 As Point, p2 As Point) As Boolean
If p1 Is Nothing OrElse p2 Is Nothing Then
Return False
End If
If p1.GetType() Is p2.GetType() Then
Return (p1.X = p2.X) AndAlso (p1.Y = p2.Y)
End If
Return False
End Operator
''' <summary>
''' This operator determines whether two Points have the
''' same location.
''' </summary>
''' <param name="p1"><c>p1</c> is the first Point to be comapred.
''' </param>
''' <param name="p2"><c>p2</c> is the second Point to be compared.
''' </param>
''' <returns>
''' True if the Points do not have the same location and
''' the exact same type; otherwise, false.
''' </returns>
''' <seealso cref="Equals"/>
''' <seealso cref="op_Equality"/>
Public Shared Operator <>(p1 As Point, p2 As Point) As Boolean
Return Not p1 = p2
End Operator
''' <summary>
''' This is the entry point of the Point class testing program.
''' <para>This program tests each method and operator, and
''' is intended to be run after any non-trvial maintenance has
''' been performed on the Point class.</para>
''' </summary>
Public Shared Sub Main()
' class test code goes here
End Sub
End Class
End Namespace
Berikut adalah output yang dihasilkan ketika diberikan kode sumber untuk kelas Point, yang ditunjukkan di atas:
<?xml version="1.0"?>
<doc>
<assembly>
<name>Point</name>
</assembly>
<members>
<member name="T:Graphics.Point">
<remarks>Class <c>Point</c> models a point in a
two-dimensional plane. </remarks>
</member>
<member name="F:Graphics.Point.x">
<summary>Instance variable <c>x</c> represents the point's
x-coordinate.</summary>
</member>
<member name="F:Graphics.Point.y">
<summary>Instance variable <c>y</c> represents the point's
y-coordinate.</summary>
</member>
<member name="M:Graphics.Point.#ctor">
<summary>This constructor initializes the new Point to
(0,0).</summary>
</member>
<member name="M:Graphics.Point.#ctor(System.Int32,System.Int32)">
<summary>This constructor initializes the new Point to
(<paramref name="x"/>,<paramref name="y"/>).</summary>
<param><c>x</c> is the new Point's x-coordinate.</param>
<param><c>y</c> is the new Point's y-coordinate.</param>
</member>
<member name="M:Graphics.Point.Move(System.Int32,System.Int32)">
<summary>This method changes the point's location to
the given coordinates.</summary>
<param><c>x</c> is the new x-coordinate.</param>
<param><c>y</c> is the new y-coordinate.</param>
<see cref=
"M:Graphics.Point.Translate(System.Int32,System.Int32)"/>
</member>
<member name=
"M:Graphics.Point.Translate(System.Int32,System.Int32)">
<summary>This method changes the point's location by the given
x- and y-offsets.
<example>For example:
<code>
Point p = new Point(3,5);
p.Translate(-1,3);
</code>
results in <c>p</c>'s having the value (2,8).
</example>
</summary>
<param><c>x</c> is the relative x-offset.</param>
<param><c>y</c> is the relative y-offset.</param>
<see cref="M:Graphics.Point.Move(System.Int32,System.Int32)"/>
</member>
<member name="M:Graphics.Point.Equals(System.Object)">
<summary>This method determines whether two Points have the
same location.</summary>
<param><c>o</c> is the object to be compared to the current
object.</param>
<returns>True if the Points have the same location and they
have the exact same type; otherwise, false.</returns>
<seealso cref=
"M:Graphics.Point.op_Equality(Graphics.Point,Graphics.Point)"
/>
<seealso cref=
"M:Graphics.Point.op_Inequality(Graphics.Point,Graphics.Point)"
/>
</member>
<member name="M:Graphics.Point.ToString">
<summary>Report a point's location as a string.</summary>
<returns>A string representing a point's location, in the form
(x,y), without any leading, training, or embedded
whitespace.</returns>
</member>
<member name=
"M:Graphics.Point.op_Equality(Graphics.Point,Graphics.Point)">
<summary>This operator determines whether two Points have the
same location.</summary>
<param><c>p1</c> is the first Point to be compared.</param>
<param><c>p2</c> is the second Point to be compared.</param>
<returns>True if the Points have the same location and they
have the exact same type; otherwise, false.</returns>
<seealso cref="M:Graphics.Point.Equals(System.Object)"/>
<seealso cref=
"M:Graphics.Point.op_Inequality(Graphics.Point,Graphics.Point)"
/>
</member>
<member name=
"M:Graphics.Point.op_Inequality(Graphics.Point,Graphics.Point)">
<summary>This operator determines whether two Points have the
same location.</summary>
<param><c>p1</c> is the first Point to be compared.</param>
<param><c>p2</c> is the second Point to be compared.</param>
<returns>True if the Points do not have the same location and
the exact same type; otherwise, false.</returns>
<seealso cref="M:Graphics.Point.Equals(System.Object)"/>
<seealso cref=
"M:Graphics.Point.op_Equality(Graphics.Point,Graphics.Point)"
/>
</member>
<member name="M:Graphics.Point.Main">
<summary>This is the entry point of the Point class testing
program.
<para>This program tests each method and operator, and
is intended to be run after any non-trvial maintenance has
been performed on the Point class.</para>
</summary>
</member>
<member name="P:Graphics.Point.X">
<value>Property <c>X</c> represents the point's
x-coordinate.</value>
</member>
<member name="P:Graphics.Point.Y">
<value>Property <c>Y</c> represents the point's
y-coordinate.</value>
</member>
</members>
</doc>
Visual Basic language spec