Attribute Constructor and Field/Property Data Types

  1. What types are legal to use for the public nonstatic fields and properties?
  2. How to apply attribute correctly?

To implement public members of an attribute class we can use nonstatic properties and fields only. The legal set of data types is limited to the following:

Boolean, Char, Byte, SByte UInt16, Int16, UInt32, Int32, UInt64, Int64, Single, Double, String, Object, Type. It’s also possible to pass single dimension zero based arrays, but isn’t CLS-compliant way.

When applying attribute, we must pass a compile-time constant expressions that matches the type defined by the attribute class.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s