Y
yaniv.golan
Hi,
Either I am missing something, or there is a compiler bug in the way
inheritance from generic s is treated.
In the following code, class c2 inherits from c1_generic. c1_generic
has T as a generic paramter, and in the inheritance, class c2 specifies
c3_T as the value of this parameter.
class c1_generic defines 2 constructors, 1 of them taking 1 parameter.
Attempting to instatiate an object of class c2 using this constructor
fails unless c2 also redefines this constructor.
Here is the code to reproduce the problem:
// base generic class. defines 2 constructors, one of them taking 1
parameter
public class c1_generic<T> {
public c1_generic() {
}
public c1_generic(object o) {
}
}
// inherit from c1_generic, with c3_T as the generic class parameter
public class c2 : c1_generic<c3_T> {
// if you remove this constructor, it won't work - complains that
// it doesn't find a constructor taking 1 parameter, even though such
a
// constructor is defined in the parent class
public c2(object o) : base(o) {
}
}
public class c3_T {
}
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
// if you remove the constructor in c2, this
fails - it can't find
// the constructor defined in c1_generic:
c2 o = new c2(this);
}
Comments?
Thanks,
YanivG
Either I am missing something, or there is a compiler bug in the way
inheritance from generic s is treated.
In the following code, class c2 inherits from c1_generic. c1_generic
has T as a generic paramter, and in the inheritance, class c2 specifies
c3_T as the value of this parameter.
class c1_generic defines 2 constructors, 1 of them taking 1 parameter.
Attempting to instatiate an object of class c2 using this constructor
fails unless c2 also redefines this constructor.
Here is the code to reproduce the problem:
// base generic class. defines 2 constructors, one of them taking 1
parameter
public class c1_generic<T> {
public c1_generic() {
}
public c1_generic(object o) {
}
}
// inherit from c1_generic, with c3_T as the generic class parameter
public class c2 : c1_generic<c3_T> {
// if you remove this constructor, it won't work - complains that
// it doesn't find a constructor taking 1 parameter, even though such
a
// constructor is defined in the parent class
public c2(object o) : base(o) {
}
}
public class c3_T {
}
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
// if you remove the constructor in c2, this
fails - it can't find
// the constructor defined in c1_generic:
c2 o = new c2(this);
}
Comments?
Thanks,
YanivG