Using system;
Using system. Collections. Generic;
Using system. text;
Using system. reflection; // use reflection
Namespace Cui. useattribute
{
// Apply the attributeusage feature to control the usefulness of this feature
[Attributeusage (attributetargets. All, allowmultiple = false, inherited = true)]
Public class myattribute: attribute // must inherit from Attribute Class
{
Private string _ username; // User Name
Private string _ lastlogintime; // Last Logon Time
Private string _ remark; // remarks
[My ("Jie", "2008-05-06", remark = "Hello, I'm Jie.")]
Public class usemyattribute
{
Public void saysomething ()
{
Console. writeline ("Say something ");
}
}
Public class test
{
Public static void main ()
{
Type type = typeof (usemyattribute );
Myattribute = attribute. getcustomattribute (type, typeof (myattribute) as myattribute;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.