No you can not have constructors on interfaces for the reasons that have been posted. However you can on abstract classes. Lets say for example you have this base class.
public abstract class ClassOne
{
protected int _x;
protected string _s;
public ClassOne(int x, string s)
{
_x = x;
_s = s;
}
}
Notice there is no constructors that takes no argument (default constructor) which means any class that inherits from ClassOne must call the constructor that has 2 arguments.
So this is not valid and will not compile.
public class ClassTwo : ClassOne
{
public ClassTwo()
{ }
}
However this is valid and will compile.
public class ClassTwo : ClassOne
{
public ClassTwo(int x, string s) : base(x, s)
{ }
}
I would like to point out here that in C# you can only inherit from one base class. Meaning that this may not be the correct solution for particular situation but is something to think about.
Tony.