C# .NET - Attributes in C#2 0 - Asked By jason smith on 22-Aug-06 11:47 AM

am trying to learn C# (2.0). 

I think I am okay with the concept of Generics now and I have done some decent number of sample code. 

I came across Attributes and I am trying to find out how often they are useful in the real world and under what circumstances they are used. If they are not of great help I would like to skip (for now) and start learning about Delegates. 

any suggestions will be very helpful 

Attributes are used throughout the NET Framework - Asked By Peter Bromberg on 22-Aug-06 11:57 AM

It's a class, and it is used to annotate or add additional infrastructure or transport information to an assembly, a class, method, or field.

for example, if you look in your AssemblyInfo.cs file, you will see attributes for the assembly.

If you look at a WebService method you will see the attribute "WebMethod". etc.

Now you can move on to Delegates.

thanks Peter - Asked By jason smith on 22-Aug-06 12:17 PM


There are all sorts of uses for custom attributes - Asked By Robbe Morris on 22-Aug-06 01:19 PM

Here is one that I rely on alot.  It use them to auto populate custom classes from DataTables.

this focuses on attributes themselves.


This is an updated version utilizing generics and attributes:

thanks much - Asked By jason smith on 22-Aug-06 03:30 PM