| Using VISA.NET > API Structure > Enumerations |
An enumeration specifies a limited set of discrete values. Enumerations ensure that valid values are used and enable Visual Studio to present the list of valid values to developers, using IntelliSense.
VISA C does not have enumerations. Instead it uses integer attributes for which a few discrete values are defined using the #define preprocessor directive. You can use values other than the defined values, but they result in an error. The only thing that ensures that developers will use the defined values is the discipline of the developer in following the specification.
VISA.NET uses enumerations extensively. This has the benefit of ensuring that valid values are always used for an enumerated type variable. If you try to use a value that is not defined as part of the enumeration, you get a syntax error at build time.
![]() |
There is not always a clear one-to-one correspondence between VISA defined constants and VISA.NET enumerated values. If you have any doubt about the meaning of a VISA.NET enumerated value, rely on this VISA.NET documentation rather than making assumptions based on your knowledge of VISA. |
By default, .NET enumerated types are based as Int32 (int), and values can be converted to integer values unless otherwise specified. VISA.NET enumerations are based as Int32 with one exception: The StatusByteFlags enumeration is based as Int16 because it represents a 16-bit register.
Generally, VISA.NET enumerations are zero-based – that is, they contain a default value assigned to 0 (zero). There are exceptions for certain enumerations where compatibility with the VISA constant values was a consideration.
By default, a .NET enumerated type variable can have only a single enumerated value assigned. However, in some case it is necessary to have a combination of values assigned. If an enumeration is decorated with the Flags attribute, you may OR multiple values together to represent a combination of values. There are five flags enumerations in VISA.NET:
In some cases, enumerations are not suitable for representing defined values. For example, NativeErrorCode contains a list of VISA error codes that may be included in exceptions that are thrown when an error is returned from an underlying VISA implementation. Representing these values in a class instead of an enumeration allows vendors to extend the class with vendor specific error codes if needed.