title: Passing interface as a parameter to the Class constructor
body: <p>I'm working with iText7 to read the PDF file data and create an xml file based on their location in the PDF file.
  My problem is, </p>
  
  <p>There is a class <code>LocationTextExtractionStrategy</code> in iText7 assembly which is as shown below</p>
  
  <pre><code>public class LocationTextExtractionStrategy : ITextExtractionStrategy, IEventListener
  {
      public LocationTextExtractionStrategy(ITextChunkLocationStrategy strat);
      public virtual void EventOccurred(IEventData data, EventType type);
  
      public interface ITextChunkLocationStrategy
      {
          ITextChunkLocation CreateLocation(TextRenderInfo renderInfo, LineSegment baseline);
      }
  }
  </code></pre>
  
  <p>Now I inherited this class into my project class as shown below</p>
  
  <pre><code>public class TextLocationExtractionStrategy : LocationTextExtractionStrategy
  {
      ITextChunkLocationStrategy locationstrategy ;
      public TextLocationExtractionStrategy(ITextChunkLocationStrategy strategy)
      {
          locationstrategy = strategy;
      }
  
      public override void EventOccurred(IEventData data, EventType type)
      {
          if (!type.Equals(EventType.RENDER_TEXT))
              return;
  
          TextRenderInfo renderInfo = (TextRenderInfo)data;
  
          string curFont = renderInfo.GetFont().GetFontProgram().ToString();
  
          float curFontSize = renderInfo.GetFontSize();
  
          IList&lt;TextRenderInfo&gt; text = renderInfo.GetCharacterRenderInfos();
          foreach (TextRenderInfo t in text)
          {
              LineSegment lineSegment = t.GetBaseline();
              string letter = t.GetText();
              Vector letterStart = t.GetBaseline().GetStartPoint();
              Vector letterEnd = t.GetAscentLine().GetEndPoint();
              Rectangle letterRect = new Rectangle(letterStart.Get(0), letterStart.Get(1),
                  letterEnd.Get(0) - letterStart.Get(0), letterEnd.Get(1) - letterStart.Get(1));
  
              if (letter != " " &amp;&amp; !letter.Contains(' '))
              {
                  ITextChunkLocation loc = locationstrategy.CreateLocation(t, lineSegment);
                  UTextChunk chunk = new UTextChunk(t, t.GetText(), loc);
                  t.GetText();
                  t.GetBaseline().GetBoundingRectangle();
  
                  m_locationResult.Add(chunk);
              }
          }
      }
  }
  </code></pre>
  
  <p>In the <code>EventOccurred</code> method, I have called the <code>CreateLocation</code> method of the base class (inside the <code>if</code> condition).</p>
  
  <p>Now my problem is, how can I pass an interface as a parameter to the Constructor of my derived class, so that I can easily call <code>CreateLocation</code> method of the base class?</p>
  
  <p>I'm trying as shown below, but I don't understand how can I create a proper object or something else which can be passed to the constructor with the help of which I can call <code>CreateLocation</code> method.</p>
  
  <pre><code>LocationTextExtractionStrategy.ITextChunkLocationStrategy locst = null;
  TextLocationExtractionStrategy strategy = new TextLocationExtractionStrategy(locst);
  PdfTextExtractor.GetTextFromPage(page, strategy))
  </code></pre>
  
  <p>As we can't create an instance of an interface, I don't know how to pass value to a parameter of type interface. In the above lines I just assigned it to null and calling the constructor, but with null value assigned to it, it'll say "object reference not set to an instance of an object". </p>
  
  <p>Can you please help me in resolving this issue.</p>
  
  <p>Please let me know or correct me if there is any issue in the way of presenting my question.</p>