Question Structure

Joined
Mar 1, 2011
Messages
14
Programming Experience
Beginner
hi
i have class about USB and this class contain Structure
when compile this class show this error:

Structure 'GUID_DEVINTERFACE' must contain at least one instance member variable or Event declaration.

VB.NET:
Public Structure GUID_DEVINTERFACE
                Public Const DISK As String = "53f56307-b6bf-11d0-94f2-00a0c91efb8b"
                Public Const HUBCONTROLLER As String = "3abf6f2d-71c4-462a-8a92-1e6861e6af27"
                Public Const MODEM As String = "2C7089AA-2E0E-11D1-B114-00C04FC2AAE4"
                Public Const SERENUM_BUS_ENUMERATOR As String = "4D36E978-E325-11CE-BFC1-08002BE10318"
                Public Const COMPORT As String = "86E0D1E0-8089-11D0-9CE4-08003E301F73"
                Public Const PARALLEL As String = "97F76EF0-F883-11D0-AF1F-0000F800845C"
            End Structure
sorry for my bad english
 
Last edited:
Constants are shared members. A Structure is a custom type that should logically represent a single value, which yours doesn't do, so declare it as Class.
Actually an Enum would be better, but that only supports primitive underlying types and not string values.
 
thanks in advanced

"Thanks in advance" means that you are thanking someone for something that they are going to do in the future. As the help has already been provided, you should say "thanks in retrospect" or, more usually, just "thanks".
 
If you want a type that contains only constants then a module would be a logical option.
A module (static class) is logically more appropriate, but the type promotion is annoying for uses like this, especially if there are to be multiple constructs like this (very common with API declarations). I think I'd rather use a Class, and if necessary add a private constructor. When used similar to a Enum it is also not likely that one would accidently add instance members.
 
Back
Top