Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any other useful attributes for c# properties? [duplicate]

Possible Duplicate:
Most Useful Attributes in C#

besides:

[DefaultValue(100)]
[Description("Some descriptive field here")]
public int MyProperty{get; set;}

What other C# Attributes are useful for Properties, after learning these I feel like I'm Missing out.

Related Questions

Most Useful Attributes in C#

like image 290
maxfridbe Avatar asked Oct 16 '08 20:10

maxfridbe


People also ask

What are the attributes used in C?

attr1 appertains to the variable declarations a and b, attr2 appertains to the type int, attr3 appertains to the variable declaration a, and attr4 appertains to the variable declaration b.

What is the use of __ attribute __ in C?

The __attribute__ directive is used to decorate a code declaration in C, C++ and Objective-C programming languages. This gives the declared code additional attributes that would help the compiler incorporate optimizations or elicit useful warnings to the consumer of that code.

What are class attributes C++?

Attributes and methods are basically variables and functions that belongs to the class. These are often referred to as "class members". A class is a user-defined data type that we can use in our program, and it works as an object constructor, or a "blueprint" for creating objects.

Which of the following forms the attributes of a function?

Like other objects, a function is defined by a set of attributes. It shares many of the attributes of variables, including identifier, title, units, description, and definition, inputs, and outputs.


2 Answers

[Obsolete("This is an obsolete property")]

That's one of my favourites. Allows you to mark a property/method obsolete, which will cause a compiler warning (optionally, a compiler error) on build.

like image 120
TheSmurf Avatar answered Sep 28 '22 07:09

TheSmurf


Just a few...

synchronization, inlining, etc:

[MethodImpl]

component model:

[TypeDescriptor], [DisplayName], [Editor]

serialization:

[Serializable], [DataMember], [XmlElement], [XmlAttribute], [NonSerialized], etc

declarative security:

[PrincipalPermission]

all the COM stuff...

like image 41
Marc Gravell Avatar answered Sep 28 '22 08:09

Marc Gravell