Results 1 to 6 of 6

Thread: [2.0] what are attributes

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    [2.0] what are attributes

    I am aware of interfaces, methods, classes and properties. what are attributes?

    any sites that would give good introduction about attributes in c#?

    thanks
    nath

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] what are attributes

    Attributes control how a type or member interacts with the IDE, compiler, etc. Attributes themselves are classes. Take for example the System.ComponentModel.CategoryAttribute class. You apply it to a property declaration and it controls which category the property appears under in the Properties window at design time. Note that all attribute classes inherit the Attribute class, either directly or indirectly, and it is convention to end their name in "Attribute". When you apply an attribute in code you normally drop the "Attribute" suffix. For instance, this code:
    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace WindowsApplication2
    {
        class MyTextBox : System.Windows.Forms.TextBox
        {
            private string _version = "1.0.0.0";
    
            [System.ComponentModel.Category("Wunnell")]
            public string Version
            {
                get { return _version; }
            }
    	
        }
    }
    produced the result below when an instance of the class was added to a form in the designer.
    Attached Images Attached Images  
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

  4. #4

  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: [2.0] what are attributes

    In addition: Attributes are a way of specifying certain types of Metadata.
    I don't live here any more.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    Re: [2.0] what are attributes

    popski,

    that was a great reply. the link was a great resource.

    thanks jm

    nath

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width