Interface between libraries

  • Thread starter Thread starter Alphapage
  • Start date Start date
A

Alphapage

Hello,

I build a library and I want to let other developers to add some features to
my library.

For example, I want to provide an interface or abstract class (?) like this:
interface IExample
{
string getstring;
}
So, they implement this interface in their library like this:
class Example:IExample
{
string getstring()
{
return "a string from the developer library";
}
}

The problem is how can I get this string from my own library or is it the
wrong way ?

Thanks in advance for your help.
 
Alphapage said:
I build a library and I want to let other developers to add some features to
my library.

For example, I want to provide an interface or abstract class (?) like this:
interface IExample
{
string getstring;
}
So, they implement this interface in their library like this:
class Example:IExample
{
string getstring()
{
return "a string from the developer library";
}
}

The problem is how can I get this string from my own library or is it the
wrong way ?

If your code has a reference to something that implements/inherits
from the interface/abstract class, then your code can call it just
like any other call.

If their code pass the reference to you then you are all set.

If you need to instantiate the object of their class, then
you will need to use reflection.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top