views:

58

answers:

1

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

CodeKey Description

GetList GetSpecific SetProperties

All of my classes implement this. I am hesitent, however, to use an interface because of one problem--the type Codes vary by type. Some are strings, some are integers, some are bytes. The only way I could see using an interface would be to make the typeCode an object in the interface and then cast whenever I needed to use it, but that seems a bit silly. Any ideas? This is in VB.NET. Thanks for the help! :)

+1  A: 

You could use a 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 am not sure I understand your question completely, but your type issue is an obvious use of generics.

Good luck, - Dan

AnotherDan
Dan,Thanks so much. This was exactly the same conclusion I came to searching around Google. It looks like it is going to work perfectly and prevent much casting :) Thanks a bunch!In Christ,Austin
Austin