I
Ian Semmel
I haven't used interfaces before, but I thought I'd come across a reason
for using them.
Suppose I have :
public interface ILogger
{
void LogLine(string s);
void LogLine(object o);
}
and somewhere else I have :
public abstract class Log : ILogger
{
public void LogLine ( string s ) { . }
public void LogLine ( object o ) { . }
}
So far so good.
Now if later on again I declare :
protected ILogger log;
I can write statements
log.LogLine ( "sss" );
This all compiles OK.
BUT
It appears I can's set a property
public ILogger
{
set { log = value; }
}
What I'm trying to do is use the same code for WindowsForms and Web
code. The logging method is different for both.
I presume I can use abstract classes, but this is what I thought
interfaces were for.
for using them.
Suppose I have :
public interface ILogger
{
void LogLine(string s);
void LogLine(object o);
}
and somewhere else I have :
public abstract class Log : ILogger
{
public void LogLine ( string s ) { . }
public void LogLine ( object o ) { . }
}
So far so good.
Now if later on again I declare :
protected ILogger log;
I can write statements
log.LogLine ( "sss" );
This all compiles OK.
BUT
It appears I can's set a property
public ILogger
{
set { log = value; }
}
What I'm trying to do is use the same code for WindowsForms and Web
code. The logging method is different for both.
I presume I can use abstract classes, but this is what I thought
interfaces were for.