title: So a VB interface can't have shared functions. Is there an alternative to creating dummy objects?
body: <p>To avoid getting into the weeds on my particular program, let me just create a simplified case.</p>
  
  <p>I have a generic class that should work on a variety of objects. Each of those objects must implement a certain interface.</p>
  
  <p>What I WANT to say is something like:</p>
  
  <pre><code>Public Interface GenThing
      Shared Function thing_name() As String ' This doesn't work! Can't be shared!
      Sub FillOne(row As DataRow)
  End Interface
  
  public class Thing1
    implements GenThing
      public shared function thing_name() as string implements GenThing.thing_name
          return "thing number one"
      end function
  
      public sub FillOne(row as DataRow) implements GenThing.MakeOne
          ... bunch of work ...
      end sub
  end class
  
  public class ThingUtil(of T as {GenThing,New})
      public function GetList(id as integer) as List(of T)
        dim name=T.thing_name() ' This doesn't work!
        dim ds as DataSet=GetData(name,id) ' bunch of work here that's the whole point of the class but not relevant to the question
        dim my_list = new List(of T)
        for each row as DataRow in ds.tables(0).rows
            dim my_t = new T()
            my_t.FillOne(row)
            my_list.add(my_t)
        next
        return my_list
      end function
  end class
  </code></pre>
  
  <p>Do you get my problem? I need every class that implements the interface to have a function that returns a "name" that is used to get the data that is needed to create an instance of the object. But I need to know this name BEFORE I create the instance, because I need it to be able to create the instance. But VB doesn't allow an interface to have a shared function, so what I want to write doesn't work.</p>
  
  <p>So what I've done is this:</p>
  
  <p>I make thing_name not shared.</p>
  
  <p>Then instead of simply "dim name=T.thing_name()", I write</p>
  
  <pre><code>dim dummy = new T()
  dim name = dummy.thing_name()
  </code></pre>
  
  <p>Okay, it works, but it seems really ugly. I create an instance of the object, with all the overhead that that involves, just to get a piece of constant text.</p>
  
  <p>Is there a better way? Or am I making a big deal out of nothing?</p>
  
  <p><em>Update</em></p>
  
  <p>I see that two people voted to close this question on the grounds that it is the same as "Why can't we have shared functions in an interface?"</p>
  
  <p>I am not asking why I can't have a shared. I am saying, GIVEN that I can't, how do I solve this particular problem?</p>