ProAnswers.org

Useful Attributes in c# ?

I know that attributes are extremely useful. There are some predefined ones such as [Browsable(false)] which allows you to hide properties in the properties tab.
What are the predefined attributes (and their namesapce) you actually use in your projects?

[DebuggerDisplay] can be really helpful to quickly see customized output of a Type when you mouse over the instance of the Type during debugging. example:

			[DebuggerDisplay("FirstName={FirstName}, LastName={LastName}")] 
			class Customer 
			{ 
			    public string FirstName; 
			    public string LastName; 
			} 
			 
	



 



Also, it is worth mentioning that [WebMethod] attribute with CacheDuration property set can avoid unnecessary execution of the web service method.