hi

I am trying to learn some basics about attributes in c#. As per i have refered, an attributes is just an additional information that is added to the programming elements.

I just want to know, what is the difference between attributes and properties.

Why we are moving to attributes. Before attributes what is used.

this is basics and silly question but i need to get a clear picture about this.

Please let me know ASAP

From Eric Lippert's blog:

Think about a typical usage of attributes:

[Obsolete]
[Serializable]
public class Giraffe : Animal
{ ...

Attributes typically do not have anything to do with the semantics of the thing being modeled. Attributes are facts about the mechanisms - the classes and fields and formal parameters and whatnot. Clearly this does not mean "a giraffe has an obsolete and a serializable." This also does not mean that giraffes are obsolete or serializable. That doesn't make any sense. This says that the class named Giraffe is obsolete and the class named Giraffe is serializable.

In short: use attributes to describe your mechanisms, use properties to model the domain.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.