Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
From the author of

Attributes Everywhere You Turn

Although assembly and type metadata are important for the CLR to function, attributes are just special .NET types that contain data that is stored with the assembly and types. Throughout the .NET Framework, attributes are used to describe different ancillary information or behaviors of classes. For example, .NET serialization uses the Serializable and NonSerialized attributes to specify that a class can be serialized, as well as what members not to serialize:

public class MySpecialClass
 // Serializable since the class is
 // marked with the Serializable attribute
 public string dataOne;
 public string dataTwo;
 public string dataThree;
 public string dataFour;

 // Not serializable since we marked it
 public string dataFive;


But what exactly are attributes? Peering into the System.Reflection.Attribute class will help answer that question.

  • + Share This
  • 🔖 Save To Your Account