这篇文章将为大家详细讲解有关VB.NET中有哪些特殊操作符,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
VB.NET特殊操作符的小例子如下:
Dim a As New dog
Dim b As New dog
Dim c As Type
c = a.GetType
MsgBox(c.ToString)
If TypeOf (a) Is vb1.
Form7.dog Then
MsgBox(True)
End If
'vb1.Form7+dog
'True
就说这么多吧。已有在应用中如果在总结出什么好的经验,再慢慢补充。
任何一门语言都提供了丰富的操作符,vb也不例外。操作符一般分为:算术运算符,赋值运算符,比较运算符,逻辑运算符,以及VB.NET特殊操作符。本文只以几个小例子来介绍其中一些比较重要的应用。
在本文中将会用到一个自定义类 dog ,代码如下:
Public Class dogClass dog
Private s_name As String
Private s_color As Color
Private s_age As Integer
Public Sub New()Sub New()
s_name = "塞北的雪"
s_age = 22
s_color = System.Drawing.Color.Red
End Sub
Public Property Name()Property
Name() As String
Get
Return s_name
End Get
Set(ByVal value As String)
s_name = value
End Set
End Property
Public Property Color()Property
Color() As Color
Get
Return s_color
End Get
Set(ByVal value As Color)
s_color = value
End Set
End Property
Public Property Age()Property
Age() As Integer
Get
Return s_age
End Get
Set(ByVal value As Integer)
s_age = value
End Set
End Property
Public Shared Operator +(ByVal a
As dog, ByVal b As dog)
Dim c As New dog
c.Name = a.Name + b.Name
c.Age = a.Age + b.Age
c.Color = Color.FromArgb((a.Color.
ToArgb + b.Color.ToArgb) / 2)
Return c
End Operator
End Class
关于VB.NET中有哪些特殊操作符就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。