Should I use an interface for Type Codes?

I am working on a project that has several different codes. These codes are mainly used this way:

CodeKey
Description

GetList
GetSpecific
SetProperties

      

All my classes implement this. However, I hesitate to use the interface because of one problem - the types of codes differ in type. Some of them are strings, some are integers, some are bytes. The only way I could use the interface was to make the typeCode an object in the interface and then throw when I needed to use it, but that seems a little silly. Any ideas? It's in VB.NET.

0


a source to share


1 answer


You can use the generic interface for it as I read it.

Interface IYourType(Of T)
  Property CodeKey As T
  Property Description As String
  Sub GetList...
  Sub GetSpecific...
  Sub SetProperties...
End Interface

      



I'm not sure I fully understand your question, but the type issue is the obvious use of generics.

Good luck - Dan

+1


a source







All Articles