sách gpt4 ăn đã đi

c# - 系统.StackOverflowException

In lại Tác giả: Walker 123 更新时间:2023-11-30 13:12:42 27 4
mua khóa gpt4 giày nike

请帮助我解决 System.StackOverflowException我想用 .aspx 将记录写入数据库我使用 4 层架构来实现这一切都正常但是当我编译页面然后它显示要插入数据的字段时,当我将数据插入这些字段并单击提交按钮然后显示 System.StackOverflowException 发生

public class Customers
{
public Customers()
{
int CustomerID = 0;
string Fname = string.Empty;
string Lname = string.Empty;
string Country = string.Empty;
}
public int CustomerID
{
get { return CustomerID; }
set { CustomerID = value; }
}
public string Fname
{
get { return Fname; }
set { Fname = value; }****
}
public string Lname
{
get { return Lname; }
set { Lname = value; }
}
public string Country
{
get { return Country; }
set { Country = value; }
}

当页面执行时弹出一个窗口并显示 System.StackOverflowException occurred 请给我解决这个问题的方法

câu trả lời hay nhất

public int CustomerID
{
get { return CustomerID; }
set { CustomerID = value; }
}

您正在递归地将值分配给自身。其他属性也一样。

您需要用另一个名称定义一个备份字段,例如:

private int _CustomerId;
public int CustomerID
{
get { return _CustomerID; }
set { _CustomerID = value; }
}

或者更好:

public int CustomerId {get; set;}

关于c# - 系统.StackOverflowException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1672547/

27 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress