我有一个类MyDataRow
,它派生自DataRow
,这是我的代码:
public partial class MyDataRow : DataRow
{
internal MyDataRow(DataRowBuilder builder)
: base(builder)
{
// Initialization of variables
}
}
该类是部分类并且没有成员,因为它部分存在于原型(prototype)文件中(成员也在那里定义)。
尝试构建它会产生错误 CS1729:“System.Data.DataRow”不包含采用 0 个参数的构造函数。
我有点没有想法,因为我用 : base(builder)
明确地调用它。
我错过了什么? :)
编辑:根据要求,这是原型(prototype)部分:
message SampleDataRow
{
enum SomeEnum
{
ImAValue = 1;
MeToo = 2;
}
// Some more enums...
optional double _member1 = 30 [default = 0];
optional double _member2 = 31 [default = 0];
// More members...
}
最佳答案
Protocol Buffers 为我的部分类的原型(prototype)部分创建了一个没有参数的默认构造函数,这导致了这个错误。 感谢 Matthew Watson 指出这一点。
在我的案例中,放弃此类的 C# 部分并单独使用原型(prototype)定义将是一个可行的解决方案。
关于c# - "' BaseClass ' does not contain a constructor that takes 0 arguments."部分 C#/Protobuf 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16394567/