国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

元數(shù)據(jù)--自定義屬性(VB.NET)

2024-07-10 13:00:47
字體:
供稿:網(wǎng)友
類文件:(class1)
imports system
imports system.reflection
<attributeusage(attributetargets.all, allowmultiple:=true, inherited:=true)> _
public class class1
inherits system.attribute
private familyname as string
private givenname as string
public sub new(byval familyname as string)
me.familyname = familyname
end sub
public overrides function tostring() as string
return string.format("author:{0}{1}", familyname, givenname)
end function
public property family() as string
get
return familyname
end get
set(byval value as string)
familyname = value
end set
end property
public property given() as string
get
return givenname
end get
set(byval value as string)
givenname = value
end set
end property
end class


--------------------------------------------------------------------------------

使用自定義屬性的文件(form3.vb)

<class1("watkins", given:="damien"), class1("abrams")> _
public class form3
inherits system.windows.forms.form

private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click
dim t as type = type.gettype("windowsapplication6.form3")
dim attributes as object() = t.getcustomattributes(true)
console.writeline("custom attributes are: ")
for each o as object in attributes
console.writeline(o)
next
end sub
end class



發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 雅江县| 满城县| 甘南县| 兴和县| 罗源县| 长春市| 泽州县| 河曲县| 宁南县| 元谋县| 定远县| 卢氏县| 开化县| 兴文县| 武邑县| 噶尔县| 渭南市| 黔东| 布尔津县| 久治县| 库尔勒市| 德州市| 重庆市| 体育| 芮城县| 乡宁县| 聊城市| 前郭尔| 志丹县| 江永县| 江华| 历史| 惠州市| 平安县| 灵璧县| 阜宁县| 云梦县| 普安县| 呼伦贝尔市| 昆山市| 乌鲁木齐县|