定义类的属性时出现异常

时间:2017-09-17 00:39:37

标签: c# .net

我正在使用VS在C#中开发数据库应用程序。我有一个名为Crew的类,它有自己的字段,如名称,出生日期等等。我希望用户指定一些字段,而其他字段由应用程序本身自动计算/计算出来。如年龄要从出生日算起。我是这样做的:

var resource = {
  "majorDimension": "ROWS",
  "values": [[new Date()]]
}
var spreadsheetId = "### SpreadsheetID ###";
var range = "Sheet1!A:A";
var optionalArgs = {valueInputOption: "USER_ENTERED"};
Sheets.Spreadsheets.Values.append(resource, spreadsheetId, range, optionalArgs);

在调试时,我填写了一个人的字段并点击了创建按钮以保存到数据库,但出现了以下异常:

  

发生了System.StackOverflowException   HResult = 0x800703E9 Message =抛出了类型'System.StackOverflowException'的异常。

1 个答案:

答案 0 :(得分:2)

$mapimg = "https://maps.googleapis.com/maps/api/staticmap?center=<$USER-LOCATION>&size=640x320&key=<$YOUR-KEY>"; // Include the user location in your request URL $imagedata = file_get_contents($mapimg); // Retrieve the image server side $src = base64_encode($imagedata); // Encode the image server side $imagemap = '<img src="data:image/jpg;base64,'.$src.'">'; // Create a variable to insert the image into your page 的getter中,您引用了DOB。因此,它必须访问引用DOB的{​​{1}}的getter。所以它必须访问DOB ....

在尝试获取其值时,属性无法访问自身,或者您将进入无限循环并获得SO异常。你可以通过一个存储值的DOB支持字段来解决这个问题,然后在属性getter中访问它:

DOB
相关问题