I've built a structure to handle writing of data to a file from any class or structure that implements my IObject interface (I'll come up with a better name later).

When I try to use GetType with it, as shown below, the syntax highlighter highlights GetType (line 5) and tells me it's not a member of IObject.

I'm using an interface instead of a MustInherit class because I have several structures which also implement IObject and several classes that inherit existing classes (such as Collection(of t)). Is there any way to get the type name from an interface?

I thought of using DirectCast to cast it to Object. Will that work if fromObject is a structure instead of a class?

vb Code:
  1. Public Sub New(ByVal fromObject As IObject)
  2.     Me.Object = fromObject
  3.     Me.Data = fromObject.GetData
  4.     Me.ObjectType = ObjectTypes.Other
  5.     Me.OtherTypeName = fromObject.GetType.FullName
  6. End Sub