013共享字段,方法和事件

2021-10-06 02:42:37 字數 2213 閱讀 3188

module module1

public class employee

'私有字段

private empname as string

private emptel as string

private empaddr as string

private postalcode as integer

'共享字段

shared instancecount as integer

'建構函式

public sub new()

instancecount += 1

end sub

'屬性public property name as string

getreturn empname

end get

set(byval value as string)

empname = value

end set

end property

public property tel as string

getreturn emptel

end get

set(byval value as string)

emptel = value

end set

end property

public property addr as string

getreturn empaddr

end get

set(byval value as string)

empaddr = value

end set

end property

public property pcode as integer

getreturn postalcode

end get

set(byval value as integer)

postalcode = value

end set

end property

'共享方法

public shared function getinstancdcount() as integer

return instancecount

end function

'共享事件

public event sharedevent()

public sub dosharedevent()

console.writeline("共享事件")

raiseevent sharedevent()

end sub

'事件public event instanceevent()

public sub dosomething()

console.writeline("普通事件")

raiseevent instanceevent()

console.writeline("共享事件")

raiseevent sharedevent()

end sub

'返回值的方法

public function empinfo() as string

dim result as string

result = "姓名:" & name & vbcrlf

result &= "郵編:" & pcode

return result

end function

'不返回值的方法

public sub output(byval emp as employee)

dim res as string

res = empinfo()

console.writeline(res)

end sub

end class

dim withevents eobj as new employee

sub main()

eobj.dosomething()

eobj.dosharedevent()

console.read()

end sub

public sub run_eventhandle() handles eobj.instanceevent, eobj.sharedevent

console.writeline("處理了乙個事件")

end sub

end module

初探類的字段 屬性 方法 事件

tmyevent procedure of object tmyclass class private fage integer fonhundred tmyevent procedure setage const value integer public procedure setonhundre...

CLR via C 常量,欄位和方法

常量 具有以下特性 1.c 允許定義基元型別常量,也允許定義非基元型別常量 值必須為null 2.常量被視為靜態成員 不能用static修飾 而不是例項成員。3.常量的指向和值都不允許被修改。字段 具有以下特性 1.c 允許定義任何資料型別的字段。常用的字段修飾符如下表所示 clr術語 c 術語 說...

MySQL新增欄位和修改欄位的方法

2010 11 23 15 27 佚名 網際網路 字型大小 t t mysql資料庫系統相信大家都比較熟悉了,下文對新增欄位和修改欄位的方法作了詳細的說明,供您參考學習之用。ad mysql新增欄位的方法並不複雜,下面將為您詳細介紹mysql新增欄位和修改欄位等操作的實現方法,希望對您學習mysql...