title: Interface Implement differences in C# vs Java
body: <p>I have created a binding for a java library that comes as part of an SDK for a scanner, model Honeywell Dolphin CT50. However, I have run into a bit of rut in my understanding.</p>
  
  <p>The following example is given in Java. The Create method expects a interface implementation. However, i am not aware of a similar way to override the 'onCreated' method of the interface while still accessing the class-wide variables. This is were i am having the trouble, how can i do the following in C#.</p>
  
  <p>Java:</p>
  
  <pre><code>private static BarcodeReader barcodeReader;
  private AidcManager manager;
  
  public void onCreate(Bundle savedInstanceState) {
      // create the AidcManager providing a Context and a
      // CreatedCallback implementation.
      AidcManager.create(this, new CreatedCallback() {
          @Override
          public void onCreated(AidcManager aidcManager) {
              manager = aidcManager;
              barcodeReader = manager.createBarcodeReader();
          }
      });
  
  }
  </code></pre>
  
  <p>In .NET, the compiler will not do as above and implement the interface as an anonymous type, thus I have to implement the interface. However, how can i then assign the class wide variables? </p>
  
  <p>My C#:</p>
  
  <pre><code>NameSpace Scanner {
      private static BarcodeReader barcodeReader;
      private AidcManager manager;
      protected override void OnCreate(Bundle bundle)
      {
          base.OnCreate(bundle);
          // Set our view from the "main" layout resource
          SetContentView(Resource.Layout.Main);
  
         CreateCallback callback = new CreateCallback() {  };
         AidcManager.Create(this, callback.OnCreated(AidcManager aidcManager));
      }
  
  public class CreateCallback : AidcManager.ICreatedCallback
  {
      public IntPtr Handle
      {
          get
          {
              throw new NotImplementedException();
          }
      }
      public void Dispose()
      {
          throw new NotImplementedException();
      }
      public void OnCreated(AidcManager p0)
      {
          // How can I initialize the manager and barcode reader variables in the class above from here?
      }
    }
  }
  </code></pre>