asp.net 无法创建引用类的示例

idfiyjo8  于 2023-04-08  发布在  .NET
关注(0)|答案(1)|浏览(182)

我刚刚使用C# Web API 4.7.2在Visual Studio中安装了一个来自NuGet的包,一切都正常工作,但是当我想要创建导入库的对象时,它出现了这个错误“无法初始化。它不是字段或属性。”。下面是我的代码:

var payment = new PaymentDto { Iinn = "1131244211", Acn = "2131244212", Trmn = "3131244213", Trn = "4131244214" };

下面是来自Package的类:

namespace TaxCollectData.Library.Dto.Content
{
    [NullableAttribute(0)]
    [NullableContextAttribute(1)]
    public class PaymentDto : IEquatable<PaymentDto>
    {
        public PaymentDto();
        protected PaymentDto(PaymentDto original);

        public long Pdt { get; set; }
        public string Pcn { get; set; }
        public string Trn { get; set; }
        public string Trmn { get; set; }
        public string Acn { get; set; }
        public string Iinn { get; set; }
        public string Pid { get; set; }
        protected virtual Type EqualityContract { get; }

        public virtual PaymentDto <Clone>$();
        [NullableContextAttribute(2)]
        public virtual bool Equals(PaymentDto? other);
        [NullableContextAttribute(2)]
        public override bool Equals(object? obj);
        public override int GetHashCode();
        [CompilerGenerated]
        public string get_Acn();
        [CompilerGenerated]
        public string get_Iinn();
        [CompilerGenerated]
        public string get_Pcn();
        [CompilerGenerated]
        public long get_Pdt();
        [CompilerGenerated]
        public string get_Pid();
        [CompilerGenerated]
        public string get_Trmn();
        [CompilerGenerated]
        public string get_Trn();
        public override string ToString();
        protected virtual bool PrintMembers(StringBuilder builder);

        [NullableContextAttribute(2)]
        public static bool operator ==(PaymentDto? left, PaymentDto? right);
        [NullableContextAttribute(2)]
        public static bool operator !=(PaymentDto? left, PaymentDto? right);
    }
}
iqjalb3h

iqjalb3h1#

我使用了这个包。paymentDto是一个记录类型。你不能通过类继承它。

相关问题