Tài liệu C Sharp part12 pdf

2 263 0
Tài liệu C Sharp part12 pdf

Đang tải... (xem toàn văn)

Thông tin tài liệu

Ví dụ 3! Creating Custom Attributes(tạo một Attributes) * Lớp tạo Attributes PHP Code: /* * Created by SharpDevelop. * NetDevelop Co., Ltd. * Author: Tuan Anh Nguyen Ngoc * Date: 11/24/2006 * Contact Information. * - Email: info.netdevelop@gmail.com * - Handheld: +84 905 202 088 */ using System; namespace AdvancedDotnet { /// <summary> /// Định nghĩa Author Attribute. /// </summary> [AttributeUsage(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.S truct,AllowMultiple=false,Inherited=false)] public class AuthorAttribute : Attribute { private string _sName; public AuthorAttribute(string name) { this._sName = name; } } } Mình không có nhiều thời gian nên các bạn có thể tự tìm hiểu thêm, chú các đến Enumerator của AttributeTargets. Sử dụng Attribute tự t ạo tương tự như sử dụng Attribute. * Lớp gọi(sử dụng) Attributes PHP Code: /* * Created by SharpDevelop. * NetDevelop Co., Ltd. * Author: Tuan Anh Nguyen Ngoc * Date: 11/21/2006 * Contact Information. * - Email: info.netdevelop@gmail.com * - Handheld: +84 905 202 088 */ using System; using System.Resources; using System.Reflection; namespace AdvancedDotnet { class MainClass { [Author("tuan anh nguyen ngoc")] public static void Main() { ///do samething } } } Quote: [Author("tuan anh nguyen ngoc")] Author chính là Attributes ta tạo ra chúc các bạn thành công! có vấn đề gì cần hỏi có thể liên hệ với mình ở thông tin trên, dauden(UDS) . this._sName = name; } } } Mình không c nhiều thời gian nên c c bạn c thể tự tìm hiểu thêm, chú c c đến Enumerator c a AttributeTargets. Sử dụng Attribute. dụng) Attributes PHP Code: /* * Created by SharpDevelop. * NetDevelop Co., Ltd. * Author: Tuan Anh Nguyen Ngoc * Date: 11/21/2006 * Contact Information. *

Ngày đăng: 15/12/2013, 02:15

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan